Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting text as "primary" in Android

While looking through the built in Android themes/styles I noticed references to textColorPrimary, textColorSecondary etc. I would like to implement this in to my own theme but cannot find any way of setting a textview (or any view) to "primary" or "secondary" etc.

Am I overlooking something or is it not possible to be done?

like image 752
AverageMarcus Avatar asked Feb 02 '11 15:02

AverageMarcus


People also ask

What is TextAppearance in Android?

TextAppearance allows you to define text-specific styling while leaving a View 's style available for other uses. Note, however, that if you define any text attributes directly on the View or in a style, those values would override the TextAppearance values.

How to Set theme Android?

Settings. Under Display Options, tap Theme. Select the theme for this device: Light—White background with dark text.

How to Add style XML in Android Studio?

xml in the your application's res/values directory. Add a root <resources> node. For each style or theme, add a <style> element with a unique name and, optionally, a parent attribute. The name is used for referencing these styles later, and the parent indicates what style resource to inherit from.

How do you color text on Android?

Android TextView – Text Color. TextView Text Color – To change the color of text in TextView, you can set the color in layout XML file using textColor attribute or change the color dynamically in Kotlin file using setTextColor() method.


1 Answers

The references you're seeing to "textColor_____" are references to color selectors. You use them with a line like 'android:textColor="?android:textColorSecondary"' in the xml definition of your TextView.

See this for more detail: http://developer.android.com/guide/topics/resources/accessing-resources.html#ReferencesToThemeAttributes

like image 109
brmcmaho Avatar answered Sep 23 '22 20:09

brmcmaho