0

I've been wanting to add a border to an ImageLayout and a Space. I've managed to add a border to an ImageLayout from this question. However, when I tried to replicate the code for a Space, it didn't work. I also tried this answer but it also didn't add a border.

How can I add a border to a Space, or is there another alternative to a Space which I can add a border to?

ImageView code:

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#FFFFFF" />
    <stroke android:width="1dp" android:color="#000000" />
    <padding android:left="1dp" android:top="1dp" android:right="1dp" android:bottom="1dp" />
</shape>

LinearLayout code:

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <corners
        android:radius="2dp"
        android:topRightRadius="0dp"
        android:bottomRightRadius="0dp"
        android:bottomLeftRadius="0dp" />
    <stroke
        android:width="1dp"
        android:color="@android:color/black" />
</shape>
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
12Mb
  • 75
  • 1
  • 2
  • 8

1 Answers1

0

You can use margin instead of padding. Margin will create a distance between two layer where padding only move the content from layer.

<solid android:color="#FFFFFF" />
<stroke android:width="1dp" android:color="#000000" />
<margin android:left="2dp" android:top="2dp" android:right="2dp" android:bottom="2dp" />
Mimu Saha Tishan
  • 2,402
  • 1
  • 21
  • 40