layer-list

Android drawable appears stretched for API <23 and correctly for API 23 and above

不羁的心 提交于 2021-02-08 05:09:51
问题 I am currently using a list selector for my listview and created it using layer-list. This is my xml code: <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/menu_arrow" android:width="18dp" android:height="36dp" android:top="5dp"/> <item android:top="0dp" android:left="5dp" android:bottom="0dp" android:right="0dp"> <shape android:shape="rectangle"> <solid android:color="@android:color/transparent"/> </shape> </item> When i build the app,

Android drawable appears stretched for API <23 and correctly for API 23 and above

倾然丶 夕夏残阳落幕 提交于 2021-02-08 05:08:01
问题 I am currently using a list selector for my listview and created it using layer-list. This is my xml code: <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/menu_arrow" android:width="18dp" android:height="36dp" android:top="5dp"/> <item android:top="0dp" android:left="5dp" android:bottom="0dp" android:right="0dp"> <shape android:shape="rectangle"> <solid android:color="@android:color/transparent"/> </shape> </item> When i build the app,

Android drawable appears stretched for API <23 and correctly for API 23 and above

萝らか妹 提交于 2021-02-08 05:05:04
问题 I am currently using a list selector for my listview and created it using layer-list. This is my xml code: <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/menu_arrow" android:width="18dp" android:height="36dp" android:top="5dp"/> <item android:top="0dp" android:left="5dp" android:bottom="0dp" android:right="0dp"> <shape android:shape="rectangle"> <solid android:color="@android:color/transparent"/> </shape> </item> When i build the app,

Using layer-list to display some drawable images

笑着哭i 提交于 2020-01-22 05:11:26
问题 Android studio 2.0 Preview 3b Hello, I have created the following layout that I want to use for a background for my app. I am using the layer-list and I want to display a bowl of peas in 2 locations. Everything looks ok in the preview, but when I run on genymotion or some cheap Chinese devices the image stretches across the screen. However, on the Android AVD, everything looks fine and on my Nexus 5 (real device) everything works ok. This is what I want and this is how it's displayed in the

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"

setBackgroundResource() discards my XML layout attributes

笑着哭i 提交于 2019-12-28 08:06:14
问题 I have a view which is used as an item in a ListView . In my custom adapter, I change the background of the view using View.setBackgroundResource() depending on the item's position in the list. (I have separate assets for the first and last items in the list.) This sets the correct background image as expected, but it has the nasty side-effect that all the padding I'd set in the XML definition of the view is completely ignored. (If I set the background drawable in the XML, and don't try to

Custom view with buttons

房东的猫 提交于 2019-12-24 15:25:49
问题 I need to build the following view: Where the buttons can be regular buttons that are accessed from java code using findViewById() method. I'm not sure if i can do that using LayerList or if I need to implement a custom view from scratch? Can anyone suggest some path that I can follow to achieve this? Update Right now I have this: What I need to do for now is: - hide what is outside the circle; - only parts of the buttons that are inside the cicle should fire the onClick event. Should I use a

Layer List ignore <size> tag

落花浮王杯 提交于 2019-12-23 16:43:23
问题 I want to create a custom Radio Button. I using with <selector> and <layer-list> to show small circle on large circle, when the user select it. But it seems to ignore the <size> tag completely! My code is bellow: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="false"> <shape> <size android:width="40dp" android:height="40dp"></size> <corners android:radius="5dp"></corners> <solid android:color="@color/blue"/> </shape> </item> <item android

How to make shadow in layer-list?

余生颓废 提交于 2019-12-22 22:23:10
问题 The problem is as follows: I need to make in app widget some actionbar like this: For this I use layer-list with shape. <?xml version="1.0" encoding="utf-8"?> <!-- Bottom 2dp Shadow --> <item> <shape android:shape="rectangle"> <solid android:color="#027668"/> <corners android:radius="12dp"/> </shape> </item> <!-- White Top color --> <item android:bottom="4dp"> <shape android:shape="rectangle"> <solid android:color="#20a18b" /> <corners android:radius="7dp" /> </shape> </item> And I get some