When I call setTextAppearance(this, android.R.style.TextAppearance_Medium)
programmatically I get medium sized font with light grey text.
However, when I use android:textAppearance="@android:style/TextAppearance.Medium"
in the xml then I get the same sized text but it is colored black.
What is the difference between these?
The relevant part of the xml file looks as following:
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@android:style/TextAppearance.Medium"
android:text="Button" />
The code looks like this:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button)findViewById(R.id.button1);
button.setText("This is a long text");
//button.setTextAppearance(this, android.R.style.TextAppearance_Medium);
}
the correct response is setTextAppearance(context, android.R.style.TextAppearance_Large);
It should not be different. The only way to get a different color is to either:
1) change the text color programatically after your setTextAppearance
or
2) Your xml files contains a android:textColor with black.
If your xml code contains the android:textColor attribute, Android will use that one, rather than the one defined in xml. If you manually setTextAppearance, the color of the style will be used.
Hence, you probably have android:textColor="#000000" in the xml for that element
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