xml-drawable

Scaling then rotating a rectangle drawable

江枫思渺然 提交于 2019-12-24 09:51:03
问题 I would like to scale a rectangle drawable downwards, then rotate it so once it is clipped by the view it resembles a trapezoid with the left side slanted: The rotation is working fine: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item > <rotate android:fromDegrees="-19.5" android:toDegrees="-19.5" android:pivotX="0%" android:pivotY="0%" > <shape android:shape="rectangle" > <solid android:color="@android:color/black" /> <

TextView width match drawableTop width

可紊 提交于 2019-12-24 04:56:06
问题 Is there someway to make TextView width match compound Drawable width (XML)? For example for xml code: <TextView android:id="@+id/textView" style="@style/TextIcons" android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawableTop="@drawable/icon_contact" android:gravity="center" android:lines="2" android:text="@string/contact_label" /> I get: |---------------------| | |-------------| | | | | | | | Drawable | | | | View | | | | | | | |-------------| | |[---Contact

Creating android RadioGroup with multiple RadioButton (Custom RadioGroup)

爷,独闯天下 提交于 2019-12-23 01:46:24
问题 I want to achieve Single RadioGroup like below image for blood group selection. How can this be done? 回答1: I created my own RadioGridLayout which include RadioGroup code and extends GridLayout. You can copy this code. For me working well. After you can use this layout in your xml and customize like grid layout. For R.styleable.RadioGridLayout_checked I used code like this: <resources> <declare-styleable name="RadioGridLayout"> <attr name="checked" format="integer" /> </declare-styleable> <

Change shape border color at runtime

旧巷老猫 提交于 2019-12-20 16:28:09
问题 I have this shape in my drawable folder: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="5dp" /> <solid android:color="#ffffff" /> <stroke android:width="2dp" android:color="#B5B5B5"/> </shape> This define a rectangle with rounded corners and I can apply it as background to any panel like this: android:background="@drawable/round_corner_shape" . Here comes the question: I have few

How to create curved bottom border rectangle in android?

血红的双手。 提交于 2019-12-19 08:09:35
问题 how to create android drawable with perfect curved bottom using xml like this : i have tried this xml, but the result didn't perfect <?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#5f9c63"/> <padding android:left="1dp" android:top="1dp" android:right="1dp" android:bottom="1dp" /> <corners android:bottomRightRadius="100dp" android:bottomLeftRadius="100dp" android:topLeftRadius="0dp" android:topRightRadius="0dp"/>

How to make bottom border in drawable shape XML selector?

 ̄綄美尐妖づ 提交于 2019-12-19 05:34:13
问题 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

Android dashed line drawable potential ICS bug

谁都会走 提交于 2019-12-18 10:40:27
问题 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

Create shape for drawable

谁说我不能喝 提交于 2019-12-12 10:08:11
问题 I have ListView , and i have a background for the list items: Is there any way to recreate this background as a shape in drawable XML? The most outer grey is not part of the item background, it is actually the ListView . 回答1: You can try following with the values of your choice. It will make the bottom two corners rounded. rounded_rectangle.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape> <gradient android:angle=

Android circular progress bar with rounded corners

北战南征 提交于 2019-12-12 07:13:02
问题 I am trying to get a circular progress bar with rounded corner as shown below. But I am not able to get the rounded corner so far I am able to get the circular progress bar. I am trying to draw it using the xml drawable. <ProgressBar android:id="@+id/onboarding_activity_progress_bar" android:layout_gravity="center" android:padding="10dp" android:layout_width="120dp" android:layout_height="120dp" style="?android:attr/progressBarStyleHorizontal" android:progressDrawable="@drawable/progressbar

Which element do I need to modify to add padding between a drawable and its enclosed elements?

自古美人都是妖i 提交于 2019-12-11 08:52:41
问题 Based on what I learned here, I was able to add some "fences" around groupings of related widgets: But, as you can see, the second/lower box is crowding the first radio button text. Which element do I need to modify to add some space? Do I need to add something to the box itself, which lives in the drawable folder and is defined like this: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <stroke android:width=