Drawing multiple shapes with ShapeDrawable in xml with Android

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

Android : Rotate Vector Image to 90 degree

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

error: cannot find symbol variable abc_ic_ab_back_mtrl_am_alpha

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

Modifying the color of an android drawable

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

android animation is not finished in onAnimationEnd

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

Using drawable resources

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>