Search code examples
androidbuttonborder

Border for button in Android


I am making the page exactly as in the image link given below But I am not getting how can I achieve the golden border for the button get started, Please help thank you

Link- http://cdn9.staztic.com/app/a/2256/2256036/muthoot-fincorp-my-jewel-box-4103-0-s-307x512.jpg


Solution

  • Create a drawable shape in your drawable folder like this,

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
      android:shape="rectangle">
      <gradient android:startColor="#FFFFFF" 
        android:endColor="#FFFFFF"
        android:angle="270" />
      <corners android:radius="3dp" />
      <stroke android:width="5px" android:color="#eecc68" />
    </shape>
    

    and in your .xml put like below,

    <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/textView1"
            android:layout_below="@+id/textView1"
            android:layout_marginLeft="52dp"
            android:layout_marginTop="39dp"
            android:background="@drawable/button"
            android:text="Button" />