Home > Enterprise >  How to design following border in android studio
How to design following border in android studio

Time:06-27

Here is the image which I want to design in android studio.

CodePudding user response:

This will give you the same image that you're looking for.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:gravity="center">
        <shape android:shape="rectangle">
            <solid android:color="@color/black" />
            <stroke
                android:width="16dp"
                android:color="@color/white" />
        </shape>
    </item>
    <item>
        <shape android:shape="rectangle">
            <stroke
                android:width="8dp"
                android:color="@color/black" />
        </shape>
    </item>
</layer-list>

CodePudding user response:

You can achieve the required output by using layer-list. In the drawable folder create a new Drawable Resource File named background.xml and replace with the following code in the file.

This is the code for background.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
 <item android:gravity="center">
    <shape android:shape="rectangle">
        <solid android:color="#5271ff" />
        <stroke
            android:width="20dp"
            android:color="#f5fffe" />
    </shape>
 </item>
 <item>
    <shape android:shape="rectangle">
        <stroke
            android:width="10dp"
            android:color="#4d75f9" />
    </shape>
 </item>
</layer-list>
  • Related