layerdrawable

android shape xml rotated drawable change color programmatically

ぃ、小莉子 提交于 2020-01-02 11:44:41
问题 This is a xml for triangle shape: <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/shape_id"> <rotate android:fromDegrees="45" android:toDegrees="45" android:pivotX="-40%" android:pivotY="87%" > <shape android:shape="rectangle" > <stroke android:width="10dp"/> </shape> </rotate> </item> </layer-list> And this is a background of a textview <TextView android:id="@+id/headlineSelect_TXT2" android:layout_width="50dp" android:layout_height="50dp"

android shape xml rotated drawable change color programmatically

我们两清 提交于 2020-01-02 11:44:32
问题 This is a xml for triangle shape: <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/shape_id"> <rotate android:fromDegrees="45" android:toDegrees="45" android:pivotX="-40%" android:pivotY="87%" > <shape android:shape="rectangle" > <stroke android:width="10dp"/> </shape> </rotate> </item> </layer-list> And this is a background of a textview <TextView android:id="@+id/headlineSelect_TXT2" android:layout_width="50dp" android:layout_height="50dp"

Drawable already belongs to another owner but does not expose a constant state

和自甴很熟 提交于 2019-12-14 00:53:03
问题 Error: Invalid drawable added to LayerDrawable! Drawable already belongs to another owner but does not expose a constant state. I suddenly noticed this error today, and I'm not sure if it was because I just updated my testing device to Android 8.0. The error message clearly states there's something wrong with setting the ripple effect on the floating action button, and indeed there is no ripple effect when the button is pressed. However, I'm not sure what is causing this problem. Actually,

Change bottom property of item of layer-list Drawable programmatically

时间秒杀一切 提交于 2019-12-10 14:46:51
问题 I am creating a LayerDrawable that creates bottom stroke but i dont know how to give bottom margin of a layer(Drawablw). <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:bottom="2dp"> .. </item> </layer-list> I want to set bottom margin like above programmatically. So far i have done this: Drawable[] list = new Drawable[2]; GradientDrawable strokeDrawable = new GradientDrawable( GradientDrawable.Orientation.TOP_BOTTOM, new int[] { strokeColor[0],

Array of images stacked next to each other, using LayerDrawable.(Displaying multiple image in single imageview)

做~自己de王妃 提交于 2019-12-08 12:58:12
问题 I have 5 images, I need to display this horizontally spaced one after the other. Instead of using 5 different images to display these 5 images in a LinearLayout with horizontal orientation, I would like to use a single image view. With LayerDrawable can I achieve this? If yes how? All I want is to place images like in the sample below, where each of 'Querstions', 'Tags', 'Users', 'Badges', 'Unanswered' would be an image. 回答1: I found the answer, this is how I did each image is of dimension 48

Diagonal line across view

余生颓废 提交于 2019-12-07 16:31:22
问题 Based on some condition, I have to diagonally cut the list cell. For this I have made diagonal drawable image using this code: diagonal_line.xml <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:top="0dp" android:bottom="0dp" > <rotate android:fromDegrees="315" android:toDegrees="315" android:pivotX="0%" android:pivotY="0%" > <shape android:shape="line" > <stroke android:width="10dp" android:color="@color/grey" /> <

android shape xml rotated drawable change color programmatically

亡梦爱人 提交于 2019-12-06 14:08:05
This is a xml for triangle shape: <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/shape_id"> <rotate android:fromDegrees="45" android:toDegrees="45" android:pivotX="-40%" android:pivotY="87%" > <shape android:shape="rectangle" > <stroke android:width="10dp"/> </shape> </rotate> </item> </layer-list> And this is a background of a textview <TextView android:id="@+id/headlineSelect_TXT2" android:layout_width="50dp" android:layout_height="50dp" android:layout_weight="1" android:background="@drawable/category_triangle_shape1" android:visibility=

Diagonal line across view

喜欢而已 提交于 2019-12-05 18:26:54
Based on some condition, I have to diagonally cut the list cell. For this I have made diagonal drawable image using this code: diagonal_line.xml <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:top="0dp" android:bottom="0dp" > <rotate android:fromDegrees="315" android:toDegrees="315" android:pivotX="0%" android:pivotY="0%" > <shape android:shape="line" > <stroke android:width="10dp" android:color="@color/grey" /> </shape> </rotate> </item> </layer-list> In list cell's xml it is used as: <ImageView android:layout

Changing color in a shape inside a layer-list programmatically

别说谁变了你拦得住时间么 提交于 2019-11-27 09:24:52
I am trying to change programmatically the color of the selectable_kachel_shape . Here is the xml file: kachel_ticked_style.xml <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:id="@+id/selectable_kachel_shape" android:shape="rectangle" > <stroke android:width="5dp" android:color="@color/headrbar_color" /> </shape> </item> <item> <rotate android:fromDegrees="45" android:pivotX="120%" android:pivotY="100%" android:toDegrees="45" > <shape android:shape="line" > <stroke android:width="40dp" android:color="@color/headrbar_color" /> </shape> </rotate> <

LayerDrawable programmatically

主宰稳场 提交于 2019-11-27 04:50:46
问题 Since my application's color theme is dynamic i can only create background drawables using colors and shapedrawables, i want to build a edittext background drawable with colors and shapes as shown below. But i want to do this programatically How to build this same drawable programatically? <item> <shape> <solid android:color="@android:color/yellow" /> </shape> </item> <!-- main color --> <item android:bottom="1dp" android:left="1dp" android:right="1dp"> <shape> <solid android:color="@android