How do I change the text color of a Button?
Use a semi-colon to separate the different style elements in the HTML button tag. Type color: in the quotation marks after "style=". This element is used to change the text color in the button. You can place style elements in any order in the quotation markers after "style=".
To select multiple button objects, click the first object, then press and hold the CTRL key while you click the other objects. Click the Style ribbon. Use the controls in the Text Style group to change the text style of a button object as follows: Click this to select a text style to apply to the objects.
You can use a Button from react-native like this and can also pass the color prop. For complex and custom buttons you can create it by your own styles using Touchables which are given by react-native you don't have to use any third-party libraries for that. The first code doesn't change the text colour.
How to Change the Background Color of Buttons. To change the background color of the button, use the CSS background-color property and give it a value of a color of your taste. In the . button selector, you use background-color:#0a0a23; to change the background color of the button.
try this:
button.setTextColor(getApplication().getResources().getColor(R.color.red)); //TAKE DEFAULT COLOR
or
button.setTextColor(0xff0000); //SET CUSTOM COLOR
or
button.setTextColor(Color.parseColor("#ff0000"));
and in xml :
<Button android:id="@+id/mybtn" android:text="text textx " android:layout_width="fill_parent" android:layout_height="wrap_content" android:textStyle="bold" android:textColor="#ff0000" /> <-- SET TEXT COLOR HERE -->
Use the android:textColor
property.
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World" android:textColor="@android:color/white" />
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