2

I want to build a button with 3 different color in the background like the attached image, and I have no idea how to do that with shapes

enter image description here

Thank you for you help.

Ed Holloway-George
  • 5,092
  • 2
  • 37
  • 66
nabenzine
  • 21
  • 3

2 Answers2

0

Use ImageButton and use above image as background of that button:

 <ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:src="@drawable/YOUR_BTN_IMG"/>
Dhruvi
  • 1,971
  • 2
  • 10
  • 18
0

1st make a xml file in drawable folder with bg1 name and put this code

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:angle="90"
        android:centerColor="#4CAF50"
        android:endColor="#2E7D32"
        android:startColor="#b5e7b7"
        android:type="linear" />
</shape>

than where ever you want it use like

<ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:src="@drawable/bg1"/>

here u change angle,start end and center color as per your requirement