I want to make a drawable for my Android button, defined as drawable.

+2 votes
asked Nov 5, 2015 in Android by CandraKnisle (140 points)
I found I could set all the borders by using a rectangle, but I got kinda stuck when I wanted it on three sides. I want for example have either the top or the bottom open.  Could anyone show me how to do this?

1 Answer

+1 vote
answered Nov 6, 2015 by Admin (1,860 points)
<?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="#FFFFFF" />
    <padding
        //android:bottom="10dp"  Remove this to avoid seeing the bottom border 
        android:left="10dp"
        android:right="10dp"
        //android:top="10dp"  Remove this to avoid seeing the top border
    />

    <corners android:radius="5dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle" >
    <padding
        android:bottom="5dp"
        android:left="5dp"
        android:right="5dp"
        android:top="5dp" />

    <solid android:color="#666666" />
</shape>
</item>
</layer-list>
Welcome to I Can Crack, where you can ask questions and receive answers from other members of the community.

68 questions

47 answers

3 comments

5,318 users

...