1

I am new to use Android XML drawables. I am trying to define a simple drawable layerlist that has a gray stroke outer rectangle with a white stroke inner rectangle. The two rectangles should all have stroke width = 1 and the inner rectangle should be just 1px smaller than the outer one. Here's my code:

<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item>
  <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <stroke
        android:width="1dp"
        android:color="@android:color/darker_gray"/>
  </shape>   
</item>

<item android:bottom="1dp" android:top="1dp" android:right="1dp" android:left="1dp">
  <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <stroke
        android:width="1dp"
        android:color="@android:color/white"/>

  </shape>   
</item>

</layer-list>

But this doesn't work. I got a solid gray box as result... How should I change the code to make it like I described?

Also, I am trying to put a drawable @drawable/image to the center of the rectangle with a margin 50dp to the borders. How should I do that?

Thank you!

Allan Jiang
  • 11,063
  • 27
  • 104
  • 165

0 Answers0