-1

Can i give the gradient color on stroke(Border) of a button. Please help me soon.

<item>
  <shape android:shape="rectangle">
    <corners  android:radius="5dp" />
    <solid android:color="#6053565B" />
    <size android:height="40dp"/>
    <stroke android:width="2px" android:color="#6053565B" />
  </shape>
 </item>
ED-209
  • 4,706
  • 2
  • 21
  • 26
Shahbaz Akhtar
  • 303
  • 2
  • 9

2 Answers2

0

Create a drawable shape in your drawable folder like this, and called it button

<?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" />
Mina Fawzy
  • 20,852
  • 17
  • 133
  • 156
0

This is a solution for your problem. You can use this if your button background is a fixed color. Im still searching for the same with a transparent button and a gradient border.

Community
  • 1
  • 1
Vijeesh
  • 181
  • 10