0

Here is a layer-list:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:drawable="@color/blue"/>
    <item
        android:drawable="@mipmap/ic_launcher_foreground"
        android:gravity="center"/>
</layer-list>

How do I set the size of the second item? In some devices, it just stretches across the entire screen. I can't use android:width and android:height cause they're for API 23 minimum. I tried adding a <shape> item above it like in this answer here: https://stackoverflow.com/a/46115699/14536109 but it still stretched across the entire screen like before.

iamdhavalparmar
  • 1,090
  • 6
  • 23

2 Answers2

0

Try this maybe it will work.

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:left="16dp"
        android:right="0dp"
        android:top="0dp"
        android:bottom="16dp"
    />
</layer-list>
iamdhavalparmar
  • 1,090
  • 6
  • 23
0

How about adding pixels to the item?

<item
    android:drawable="@mipmap/ic_launcher_foreground"
    android:gravity="center"
    android:top="dimension"
    android:right="dimension"
    android:bottom="dimension"
    android:left="dimension"/> 
Pone Thone
  • 26
  • 4
  • Do these values represent padding? How do I get `dimension`? Some answers give top, right, bottom, and left the same value, while others give top and bottom bigger values than right and left. –  Mar 02 '21 at 17:23