I have two buttons, and I want to add a gradient effect to them.
colors = new int[]{Color.parseColor("#F0E7AD"), Color.parseColor("#A68813")};
gd = new GradientDrawable(
GradientDrawable.Orientation.TOP_BOTTOM, colors);
entrarButton=findViewById(R.id.entrar);
loginButton=findViewById(R.id.login);
These buttons have visibility GONE by default. Later in the app:
runOnUiThread(new Runnable() {
@Override
public void run() {
entrarButton.setVisibility(View.VISIBLE);
entrarButton.setBackground(gd);
}
});
if(showLogin){
runOnUiThread(new Runnable() {
@Override
public void run() {
loginButton.setVisibility(View.VISIBLE);
loginButton.setBackground(gd);
}
});
}
This way, they are taking the primaryColor dfined in colors.xml. Why aren't my buttons taking the background I want?
EDIT: (Buttons in XML)
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/entrar"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:visibility="gone"
android:text="ENTRAR"
android:textColor="@color/black"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/login"
android:layout_centerHorizontal="true"
android:layout_above="@+id/entrar"
android:layout_marginTop="20dp"
android:visibility="gone"
android:textColor="@color/black"
android:text="LOGIN"/>