layer-list

How do I add padding to a bitmap and a color in a layer-list

℡╲_俬逩灬. 提交于 2019-12-03 01:19:51
I need to create a drawable with a layer-list such that the background layer is an image and the foreground is a transparent color. I am able to do that. Where I am not succeeding is adding some padding/margin so that at them bottom a piece of the images shows without the colored layer on top of it. Here is my xml. Thanks for helping. <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <bitmap android:src="@drawable/img1" /> </item> <item> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape=

Using layer-list to display some drawable images

梦想与她 提交于 2019-12-02 18:57:07
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 AVD and Nexus 5. As you can see there is no problem. <layer-list xmlns:android="http://schemas.android

How to center vector drawable in layer-list without scaling

戏子无情 提交于 2019-12-02 14:34:45
I am attempting to use a VectorDrawable in a LayerList without scaling the vector. For example: <layer-list> <item android:drawable="@color/grid_item_activated"/> <item android:gravity="center" android:drawable="@drawable/ic_check_white_48dp"/> </layer-list> The drawable ic_check_white_48dp id defined as: <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="48dp" android:height="48dp" android:viewportWidth="24.0" android:viewportHeight="24.0"> <path android:fillColor="#FFFFFFFF" android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/> </vector> The

Create layer list with rounded corners programmatically

笑着哭i 提交于 2019-11-30 12:43:47
I am currently trying to convert the following XML to be created programmatically so that I can set the top corners and bottom corners as needed throughout my project. It is a simple Layer list that has two rectangles; one on top of another. I would like to use this as a background for a few different views so it is important that the result scales. <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:bottom="20dp"> <shape android:shape="rectangle" > <size android:height="20dp" /> <solid android:color="#969595" /> <corners android:radius = "0dp" android

Shape drawable in layer-list rendered incorrectly for APIs below 23

僤鯓⒐⒋嵵緔 提交于 2019-11-30 09:04:24
Yesterday, I've switched to Android Studio version 2.1.3. Today, I've re-opened one of my projects and tried to add some layer-list drawables for use with an ImageView . For example this one: <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:width="80px" android:height="80px" android:top="0px" android:left="0px" android:right="0px" android:bottom="0px"> <shape android:shape="rectangle"> <solid android:color="@color/deep_orange"/> </shape> </item> <item android:width="60px" android:height="60px" android:top="10px" android:left="10px" android:right="10px"

Shape drawable in layer-list rendered incorrectly for APIs below 23

自作多情 提交于 2019-11-29 08:34:14
问题 Yesterday, I've switched to Android Studio version 2.1.3. Today, I've re-opened one of my projects and tried to add some layer-list drawables for use with an ImageView . For example this one: <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:width="80px" android:height="80px" android:top="0px" android:left="0px" android:right="0px" android:bottom="0px"> <shape android:shape="rectangle"> <solid android:color="@color/deep_orange"/> </shape> </item> <item

How can I recreate this background in xml?

寵の児 提交于 2019-11-27 23:10:52
I've been trying to recreate a background image in xml (as drawable). Since the background is a simple shape, it would be better if it is created as xml drawable. The is a really large gradient circle that squares off at the left, top and right border. What I've tried <?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:height="20dp" /> <gradient android:type="linear" android:startColor="@color/gradientLeft" android:centerColor="@color/gradientMiddle" android:endColor="@color

android shape with bottom stroke

删除回忆录丶 提交于 2019-11-26 23:23:41
I need to create an android shape so that only the bottom has stroke (a dashed line). When I try the following, the stroke bisects the shape right through the center. Does anyone know how to get it right? the stroke needs to be the bottom line/border. I am using the shape as a background to a TextView. Please, never mind why I need it. <?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="#1bd4f6" /> </shape> </item> <item> <shape android:shape="line" > <padding android

How can I recreate this background in xml?

ε祈祈猫儿з 提交于 2019-11-26 21:22:05
问题 I've been trying to recreate a background image in xml (as drawable). Since the background is a simple shape, it would be better if it is created as xml drawable. The is a really large gradient circle that squares off at the left, top and right border. What I've tried <?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:height="20dp" /> <gradient android:type="linear" android

Understanding Android&#39;s <layer-list>

拈花ヽ惹草 提交于 2019-11-26 09:24:35
问题 I don\'t understand how the layer-lists work. I read the official documentation with some examples but it does not work for me like expected. I want four squares which should be padded with 1dp, but nothing is like expected. Here is a screenshot scaled by 500%: (The wrong colors do not matter) As you can see the size is completely wrong and the paddings are missing. I tried to set real values like width/height and right/left/top/buttom to be sure that android get the point what I want. Here