android-drawable

Get specific drawable from state list drawable

℡╲_俬逩灬. 提交于 2019-11-30 19:35:59
I have a state list drawable, and i want to get a specific drawable from the state list drawable: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:kplus="http://schemas.android.com/apk/res-auto"> <item kplus:key_type_space_alt="true" android:state_pressed="true" android:drawable="@drawable/space_1_pressed" /> <item kplus:key_type_space_alt="true" android:drawable="@drawable/space_1_normal" /> <!-- TopNav keys. --> <item kplus:key_type_topnav="true" android:state_pressed="true" android:drawable="@drawable/tab_down" /> <item kplus

Make RelativeLayout checkable

好久不见. 提交于 2019-11-30 15:57:18
问题 I try to write my own CheckBox using RelativeLayout with TextView and FrameLayout (with selector on background) inside. I have setDuplicateParentStateEnabled(true) for FrameLayout that it take checkable status from parent, but why make RelativeLayout checkable I don't know. public class MyCheckbox extends RelativeLayout implements OnClickListener, Checkable { private static final int ID_CHECKBOX = -1234411; private static final int ID_TEXTVIEW = -1234412; private static final int ID_PARENT =

Android shape with gradient border and shadow

泪湿孤枕 提交于 2019-11-30 15:34:48
I have a png drawable for the buttons. But it image drawable has gradient and it looks bad when applying 9patch (gradient & 9patch non compatible). I want to do this with a shapes. But I can't drawing with android shapes because it's hard to me to understand it. Can you help me to draw this image with a shapes? It's contain a border gradient, orange rectangle inside with a rounded corners and shadow 120° Here you go Create your layout <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android

Android button select and press drawable

℡╲_俬逩灬. 提交于 2019-11-30 11:20:08
问题 I'm trying to make a button with state press and select, I already did the same with tabs and it works but I don't know why here does not work. I have done it like this: button_sel.xml <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="@color/azulado" android:endColor="@color/azulBrillante" android:angle="270" /> <corners android:radius="@dimen/corner_radius" /> <stroke android:width="2px" android:color="@color/blanco" />

Using a rounded corners drawable

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 10:25:15
问题 There is a nice post made by the popular Google developer Romain Guy that shows how to use a rounded corners drawable (called "StreamDrawable" in his code ) on a view efficiently. The sample itself works very well on my Galaxy S3 when in portrait mode, but I have a few issues with it: if the screen is small (for example on qvga screens), the shown images get cropped. if I have an input bitmap that is too small than how I wish to show it, the output image has its edges smeared. Even on the

What is new in Drawable Tinting in Android L Developer Preview compared to previous version?

笑着哭i 提交于 2019-11-30 08:10:11
I am working of new Android L preview and now dealing with tinting concept on drawable. I want to know if there is anything new regarding drawable tinting in Android L Developer Preview. I read this this documentation which says: The Android L Developer Preview enables you to define bitmaps or nine-patches as alpha masks and to tint them using a color resource or a theme attribute that resolves to a color resource (for example, ?android:attr/colorPrimary ). You can create these assets only once and color them automatically to match your theme. But I didn't understand how it is different from

BitmapFactory.decodeResource() returns null for shape defined in xml drawable

非 Y 不嫁゛ 提交于 2019-11-30 08:07:17
I looked through multiple similar questions, although I haven't found proper answer on my query. I have a drawable, defined in shape.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <solid android:color="@color/bg_color" /> </shape> I want to convert it to Bitmap object in order to perform some operations, but BitmapFactory.decodeResource() returns null. This is how I'm doing it: Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.shape); What am I doing wrong? Is BitmapFactory

Not able to understand how to use different density images for 1.6+?

不打扰是莪最后的温柔 提交于 2019-11-30 07:55:33
I'm trying to understand how the res/drawables images should work with different screen densities. Right now I've got a 1.5 app, and for example, I have an image that is 100x100 pixels. When used on the Droid, it scales this image so it appears to be the same size relatively on that device (all other layout scaling is handled by me, using dip units). So now I need to update my project and add three folders, right?: drawable-ldpi drawable-mdpi drawable-hdpi so I'm going to put my 100x100 image in the -mdpi folder. If I want to make a version for the -hdpi folder - how do I know how much larger

How Do I Use 'RotateDrawable'?

a 夏天 提交于 2019-11-30 07:06:38
问题 Could anyone tell me how they have got 'RotateDrawable' to work whether it be from code or XML or both? The documentation on animating Drawables is pretty poor and animation only seems to work for images. I want to be able to animate all drawables. When i tried to get a RotateDrawble from XML is just causes an exception. What is the correct function to find a RotateDrawable from XML? Many thanks Kerubu 回答1: You have to animate the "level" property, where 0 is the start value and 10000 is the

Android: Make a button with triangle shape using xml definitions (drawable)

放肆的年华 提交于 2019-11-30 06:58:55
问题 I want create this using button (TextView) by using XML definiton: In layout of the Activity I have: <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/button_arrow" <!-- I NEED IMPLEMENT THIS --> android:clickable="true" android:drawablePadding="7dp" android:gravity="center" android:drawableLeft="@drawable/music_cloud" android:onClick="exportSong" android:padding="20dp" android:text="@string/export_upload" android:textAppearance="