shapedrawable

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

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

ShapeDrawable as progressDrawable for RatingBar in Android?

时光怂恿深爱的人放手 提交于 2019-12-01 00:05:34
It seems I cannot set ShapeDrawable as progressDrawable for Ratingbar. I tried the following but failed: <RatingBar android:id="@+id/ratingbar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:numStars="5" android:stepSize="1.0" android:rating="3.0" style="@style/myRatingBar" /> myRatingbar style: <style name="myRatingBar" parent="@android:style/Widget.RatingBar"> <item name="android:progressDrawable">@drawable/ratingbar_full</item> <item name="android:indeterminateDrawable">@drawable/ratingbar_full</item> <item name=

Google Maps API v2 Android add shape drawable as marker

时光毁灭记忆、已成空白 提交于 2019-11-28 21:09:11
I've been trying to add a shape drawable as the marker icon for a marker I want to add on the map. shape looks like this (res/drawable/blue_circle.xml): <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" > <size android:width="15dp" android:height="15dp" /> <solid android:color="@color/Blue" /> </shape> and I try to add the marker like this: markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.blue_circle)); Apparently I get a NullPointer exception. Must the marker icon be a bitmap? Am I allowed to add

how to add shadow effect on drawable in android

别来无恙 提交于 2019-11-28 10:47:02
I have created chat bubble with drawable which looks fine, now I want to add shadow effect below the drawable so it make 3d effect.I don't want to use 9-pitch image. I just want to know how i can add shadow effect on this drawable. my code is ----right_bubble_chat_drawable <?xml version="1.0" encoding="utf-8"?> <shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="15dp" /> <solid android:color="@color/chatrightbubbleColor" /> <padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" /> <size

Create borders on a android view in drawable xml, on 3 sides?

为君一笑 提交于 2019-11-28 07:00:33
I want to make a drawable for my Android button, defined as drawable. I found I could set all the borders by using a rectangle, but I got kinda stuck when I wanted it on three sides. I want for example have either the top or the bottom open. Could anyone show me how to do this? Shubhayu Try doing this, though I saw it on some other post <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle" > <solid android:color="#FFFFFF" /> <padding //android:bottom="10dp" Remove this to avoid seeing the bottom

Gradient Radius as percentage of screen size

耗尽温柔 提交于 2019-11-28 06:15:01
I'm trying to create a shape drawable with radial gradient background, with radius that will adjust to the screen size (take a look at the relevant documentation ). This is my code: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <gradient android:endColor="#000" android:gradientRadius="50%p" android:startColor="#5d2456" android:type="radial" /> </shape> But it doens't seem to work. if I remove the "%p", it works, but then the radius will be static, thus not adjusting to the screen size...Any idea what's wrong

Google Maps API v2 Android add shape drawable as marker

Deadly 提交于 2019-11-27 13:31:46
问题 I've been trying to add a shape drawable as the marker icon for a marker I want to add on the map. shape looks like this (res/drawable/blue_circle.xml): <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" > <size android:width="15dp" android:height="15dp" /> <solid android:color="@color/Blue" /> </shape> and I try to add the marker like this: markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.blue_circle

How to create parallelogram shape background?

别说谁变了你拦得住时间么 提交于 2019-11-27 04:26:41
I am trying to make parallelogram background for my textview but it is not displaying properly...it display following output <layer-list > <item> <rotate android:fromDegrees="10" android:toDegrees="10" android:pivotX="-40%" android:pivotY="87%" > <shape android:shape="rectangle" > <stroke android:color="#000000" android:width="10dp"/> </shape> </rotate> </item> </layer-list> i need output like this........ As alternative to @mmlooloo's answer, whom a credit goes to, I suggest a xml-drawable solution (since you haven't emphasized exactly what kind of solution you're looking for). In the example

how to add shadow effect on drawable in android

耗尽温柔 提交于 2019-11-27 03:48:42
问题 I have created chat bubble with drawable which looks fine, now I want to add shadow effect below the drawable so it make 3d effect.I don't want to use 9-pitch image. I just want to know how i can add shadow effect on this drawable. my code is ----right_bubble_chat_drawable <?xml version="1.0" encoding="utf-8"?> <shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="15dp" /> <solid android:color="@color/chatrightbubbleColor" />