I have searched a lot but I haven't found what I want. What I’m planning to do is to change the background colour of text on a button. I’m not interested in changing the colour on click. I just want to change the background of the text on a button. Thank you.
Edit: This is a sample. I want to change the black colour if it possible.
Use this to set the text color of Button :
setTextColor(getResources().getColor(R.color.white));
or
android:textColor="@color/white"
Use this to set the background of the button :
setBackgroundResource(R.drawable.button_img);
or
android:background="@drawable/button_img"
or
android:background="@color/blue"
Maybe you should try to use RelativeLayout instead of Button. Something like this: `
<RelativeLayout
android:id="@+id/RelativeLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:clickable="true"
android:background="#ffffff" >
<TextView
android:id="@+id/TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text"
android:textColor="#ffffff"
android:background="#000000"
android:textSize="16sp" />
</RelativeLayout>`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With