xml-drawable

Android dashed line drawable potential ICS bug

拥有回忆 提交于 2019-12-02 17:30:52
The following is a dashed line, defined as a ShapeDrawable in XML: <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> <size android:height="2dp" android:width="700dp" /> <stroke android:width="1dp" android:color="@android:color/black" android:dashWidth="1dp" android:dashGap="2dp" /> </shape> This will draw a nice dotted line on several Gingerbread phones. On the Galaxy Nexus however, the dashes appear to be ignored and the shape is drawn as a contiguous line. Even more curious, an emulator running ICS will render it correctly with the dashes, it's just the

app:srcCompat - Vector drawable shows up in design preview, but doesn't show up in app

我怕爱的太早我们不能终老 提交于 2019-12-01 18:09:27
drawable/information.xml <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24.0" android:viewportHeight="24.0"> <path android:fillColor="#FF000000" android:pathData="M13,9H11V7H13M13,17H11V11H13M12,2A10,10 0,0 0,2 12A10,10 0,0 0,12 22A10,10 0,0 0,22 12A10,10 0,0 0,12 2Z"/> </vector> LayoutofCardView.xml <ImageView android:layout_width="24dp" android:background="#f00" android:layout_height="24dp" android:id="@+id/informationImageView" app:srcCompat="@drawable/information" tools:src="@drawable/information" />

XML drawable having different behavior on 4.3 and 4.1.2

大城市里の小女人 提交于 2019-12-01 04:00:18
I have the folowing drawable, <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="3dp"/> <padding android:left="1dp" android:right="1dp" android:top="1dp" android:bottom="1dp"/> <stroke android:width="1dp" android:color="#e4e4e4"/> </shape> "It supposed" to draw a border when set on background, actually on (Android 4.3 /goole nexus 7) it does , but unfortunately on (Android 4.1.2/ Samsung galaxy tab 10") it just fill all the background with the color If someone can tell me what I'm doing

How to make bottom border in drawable shape XML selector?

倖福魔咒の 提交于 2019-12-01 03:16:32
I'm trying to create a drawable shape with different states for my button. So I wrote this: <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_pressed="true" android:color="@android:color/black" > <shape android:shape="rectangle" > <solid android:color="@color/NEGATIVE_pressed" /> <stroke android:width="1dp" android:color="@color/ORANGE" /> <corners android:radius="4dp" /> </shape> </item> <item android:state_focused="true" android:color="@android:color/black" > <shape android:shape="rectangle" > <solid android:color="@color/NEGATIVE_focused" /> <stroke

XML drawable having different behavior on 4.3 and 4.1.2

可紊 提交于 2019-12-01 01:43:06
问题 I have the folowing drawable, <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="3dp"/> <padding android:left="1dp" android:right="1dp" android:top="1dp" android:bottom="1dp"/> <stroke android:width="1dp" android:color="#e4e4e4"/> </shape> "It supposed" to draw a border when set on background, actually on (Android 4.3 /goole nexus 7) it does , but unfortunately on (Android 4.1.2/ Samsung

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" />

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

How to use a shape drawable together with an image?

孤者浪人 提交于 2019-11-30 08:06:51
I have this difficulty to have both rounded corner and a background image in my LinearLayout . I know I can achive the rounded corner by using the shape drawable XML, but if I put the shape drawable as the background of my LinearLayout with android:background=@drawable/rounded_corner then I cannot assign any image to be used as a background. How can I get both a rounded corner with a background image in my LinearLayout? Any help would be appreciated. Thanks! You could use LayerDrawable , which could contain as many layers(shapes or images) as you need. You can create it either as resource or

Android button select and press drawable

情到浓时终转凉″ 提交于 2019-11-29 23:54:12
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" /> </shape> button_unsel.xml <shape xmlns:android="http://schemas.android.com/apk/res/android" android

How to draw a dot circle inside a square drawable in android?

久未见 提交于 2019-11-29 17:53:24
I want a small dot inside a square button , this is what i have tried till now as answered by azizbekian: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="rectangle"> <size android:width="100dp" android:height="100dp"/> <solid android:color="#38b0ef"/> </shape> </item> <item android:bottom="45dp" android:left="45dp" android:right="45dp" android:top="45dp"> <shape android:shape="oval"> <stroke android:width="1dp" android:color="#0c5069"/> <size android:width="20dp" android:height="20dp"/> <solid android