How to use default Android drawables
Java Usage example: myMenuItem.setIcon(android.R.drawable.ic_menu_save); Resource Usage example: android:icon=”@android:drawable/ic_menu_save”
Java Usage example: myMenuItem.setIcon(android.R.drawable.ic_menu_save); Resource Usage example: android:icon=”@android:drawable/ic_menu_save”
Here’s how I did a filled red circle with a one-pixel black border, with a white number 72 in the middle: Create an XML file in res\drawable and name it appropriately, eg red_circle_black_border.xml <?xml version=”1.0″ encoding=”UTF-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android”> <item> <shape android:shape=”oval”> <solid android:color=”@android:color/black” /> </shape> </item> <item android:top=”1dp” android:left=”1dp” android:right=”1dp” android:bottom=”1dp”> <shape android:shape=”oval”> <solid android:color=”@android:color/red” … Read more
You’ll need to combine drawablePadding and padding to get the desired result.
Try This Way , I have used the group tag outside of the image path data in vector drawable file. First Type : <vector xmlns:android=”http://schemas.android.com/apk/res/android” android:width=”24dp” android:height=”24dp” android:viewportWidth=”314.015″ android:viewportHeight=”314.015″> <group android:translateX=”314.015″ android:rotation=”90″> <path android:fillColor=”#FCD83500″ android:pathData=”M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z” /> </group> </vector> Second Type : <vector xmlns:android=”http://schemas.android.com/apk/res/android” … Read more
The name of the resource was changed in the 23.2.0 support library. Modify abc_ic_ab_back_mtrl_am_alpha to abc_ic_ab_back_material Edit: In 23.2.1 the name of the component was changed back to abc_ic_ab_back_mtrl_am_alpha Edit: In 24.0.0 the name of the component was changed to: abc_ic_ab_back_material
So after a lot of trial and error, reading different articles, and most importantly, going through the API Demos (ColorFilters.java — found in com.example.android.apis.graphics) I found the solution. For solid images, I have found it is best to use the color filter PorterDuff.Mode.SRC_ATOP because it will overlay the color on top of the source image, … Read more
Here is the actual bug related to this issue http://code.google.com/p/android-misc-widgets/issues/detail?id=8 This basically states that the onAnimationEnd method doesn’t really work well when an AnimationListener is attached to an Animation The workaround is to listen for the animation events in the view to which you were applying the animation to For example if initially you were … Read more
If you want to know the meaning of intrinsic, it is nothing but the actual property possessed by an object. In our case getIntrinsicWidth/Height simply means to provide you with the default width/height of that drawable. This returns the exact size of the drawable which you have put in the resource folder without any modification. … Read more
I ran into this issue as well. Presumably you’re using a LayerList resource drawable? That’s what I was using. Unfortunately, I found no “real” way of fixing it, it seems like a bug in the code, but I didn’t chase it down. However, I was lucky in the sense that I was setting the “buggy” … Read more
To avoid error: Binary XML file line #XXX: requires a valid src attribute inside a layer-list, use: <item android:drawable=”https://stackoverflow.com/questions/9788726/@drawable/image” /> instead of: <item> <bitmap android:src=”https://stackoverflow.com/questions/9788726/@drawable/image”/> </item>