I have buttons in my app that have a drawable in background:
<Button
android:id="@+id/loginbutton"
android:text="@string/login"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:layout_width="135dp"
android:layout_height="30dp"
android:background="@drawable/buttonshape"
android:layout_centerHorizontal="true"
android:layout_below="@+id/til"
android:layout_marginTop="50dp"
/>
The drawable:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<corners
android:radius="30dp"
/>
<solid
android:color="@color/colorPrimary"
/>
<padding
android:left="0dp"
android:top="0dp"
android:right="0dp"
android:bottom="0dp"
/>
<size
android:width="270dp"
android:height="60dp"
/>
<stroke
android:width="3dp"
android:color="#878787"
/>
If I do this:
loginButton.setBackgroundColor(Color.parseColor(getBgColor()));
Not only the color, but the entire shape of the button is changed, so no rounded corners, etc. How can I change only the color of the background, keeping the rest of things of my drawable?
Thank you.