Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the text color of a Button?

How do I change the text color of a Button?

like image 570
Jason Ching Avatar asked Jun 24 '12 09:06

Jason Ching


People also ask

How can I change the color of text in 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=".

How do I change the text style of a button?

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.

How do I change the text color of a button in react?

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 do you make colored buttons?

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.


2 Answers

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 --> 
like image 76
ρяσѕρєя K Avatar answered Sep 28 '22 16:09

ρяσѕρєя K


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" /> 
like image 20
James Cross Avatar answered Sep 28 '22 14:09

James Cross