drawable

How to load resource from another package in xml?

不羁的心 提交于 2019-12-05 03:16:37
问题 I know that exists ability to install resource xml file from another package in code like this: String resourceName = getResources().getResourceEntryName(layoutResID); String resourceTypeName = getResources().getResourceTypeName(layoutResID); Resources skinResources = getResourcesForPackage("com.my.skin"); int skinResourceId = skinResources.getIdentifier(resourceName, resourceTypeName, "com.my.skin"); mLayoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

Preventing shapes scaling in a LayeredList without using Bitmap

怎甘沉沦 提交于 2019-12-05 01:46:11
Trying to use LayerDrawable (defined in XML as layer-list) to layer several shape drawables onto one another; to be used as a background for a layout. The Android guide ( for LayerList ) says: All drawable items are scaled to fit the size of the containing View, by default. Thus, placing your images in a layer list at different positions might increase the size of the View and some images scale as appropriate. To avoid scaling items in the list, use a <bitmap> element inside the <item> element to specify the drawable and define the gravity to something that does not scale, such as "center". I

Text with shapes in drawable resource

余生长醉 提交于 2019-12-05 00:04:11
Can i create text-shape in drawable resource? I was googling much but found nothing... Here is my drawable file: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="oval"> <stroke android:width="3dp" android:color="#QQffQQ"/> <size android:width="120dp" android:height="120dp"/> </shape> </item> <item android:right="59dp" android:left="59dp"> <shape android:shape="rectangle"> <solid android:color="£22££20"/> </shape> </item> <item android:top="59dp" android:bottom="59dp"> <shape android:shape="rectangle">

ResourcesNotFoundException when resource available (API 22 and 23 devices)

房东的猫 提交于 2019-12-04 20:29:59
I get this crash only on API 22 and 23 devices. (android.content.res.Resources$NotFoundException: File res/drawable/show_empty_state.xml from drawable resource ID #0x7f080156 at android.content.res.Resources.loadDrawableForCookie(Resources.java:2640) at android.content.res.Resources.loadDrawable(Resources.java:2540) at android.content.res.Resources.getDrawable(Resources.java:806) at android.content.Context.getDrawable(Context.java:458) at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:358) at com.myProj.utils.EmptyStateView.setImage(EmptyStateView.java:55) at com

Android loading drawable into ImageView taking a lot of memory

放肆的年华 提交于 2019-12-04 19:26:24
I'm having a problem. I'm loading 9 drawables into 9 imageViews dynamically. ( drawables are different each time) The drawable id is stored in the object class so when I load this drawable I set the ImageRessource to the imageView by using imageView.setImageRessource(myObject.getRessourceId()); Everything is working fine but when the 9 drawables are loaded, I see on the Android Memory Monitor that the allocate memory reaches 80MB and I think this isn't normal... (Is it?) I tried different things to solve it: Load the drawable with the library Picasso. Use BitmapFactory.decodeResssource to

Programmatically creating icon to use as ItemizedOverlay drawable - Android

别来无恙 提交于 2019-12-04 18:25:51
I am trying to programmatically draw a parking icon to place as the drawable for an itemized overlay on a map. The icon consists of a blue square with a white 'P' in its centre of which I would like to programmatically change the colour of the square to denote different parking types. I've tried creating it via the canvas using drawRect & drawText but I cannot find a simple way of centering the text in the square and I cannot find a way to center the canvas on the coordinates - it keeps wanting to anchor from the top left hand corner. I've alternatively tried creating an XML layout to convert

Android : How can i get a image that is in drawable its size in KB, name and extension

血红的双手。 提交于 2019-12-04 18:07:00
I have a pic in res/drawable-hpdi/pic.jpg, then i have a alert box that should display the image height width size name and extension, i just cant figure out how to get it act like a file and get its size etc. Bitmap bMap = BitmapFactory.decodeResource(getResources(), R.drawable.pic); File file=new File("res/drawable-hdpi/pic.jpg"); long length = file.length(); if (!file.exists()) { length = -1; } imgInfo = "Height: " + bMap.getWidth() + "\n" + "Width: " + bMap.getHeight() + "\n" +"Size: " + length; i get the height and width i cant get the rest can someone help me ? ByteArrayOutputStream baos

How to get gravity 'bottom' working on a drawable in xml

三世轮回 提交于 2019-12-04 16:29:22
问题 I have a simple aim. I want a light grey background on my FrameLayout with a black dividing line underneath it (only undernearth, not all around). So far I have this: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="rectangle" android:gravity="center"> <solid android:color="#EEEEEE" /> </shape> </item> <item> <shape android:shape="line" android:gravity="bottom" > <stroke android:width="1dip" android

Android: Draw custom border around listview?

核能气质少年 提交于 2019-12-04 14:48:05
I've got a ListActivity with a ListView in it. I need to draw a repeating image around the border ("on top of it (I guess after the listview is renderered)) How can I hook in my own drawing code for this? You can use a FrameLayout to cause the ListView to overlap with a view that fills the entire screen. In this background view you could tile an image, or write your own custom View with your own drawing method. vsm There is no border property in ListView, as far as I know. Instead you can put ListView into a FrameLayout and set the Background color of the FrameLayout. Finally, set some padding