Viktor Brešan
Viktor Brešan

Reputation: 5521

How to get CheckBox or RadioButton textAppearance?

I have some radio buttons and/or check boxes in my layout and I would like that my TextViews that are around have the same text appearance (size, color, etc.).

Basically, I am looking for something like the following:

<TextView
    android:textAppearance="?android:attr/textAppearanceRadioButton"
    ...
/>

Is it possible to achieve this in some other way perhaps?

P.S: I do not want to change the 'default' text appearance that radio buttons and check boxes already have. Also, I am not looking for a run-time solution but the one that utilizes xml layout file.

Upvotes: 4

Views: 2064

Answers (2)

Joey
Joey

Reputation: 354724

I found it now, which seems to work at least for Theme.Holo and Theme.Holo.Light:

android:textAppearance="?android:attr/textAppearance"
android:textColor="?android:attr/textColorPrimaryDisableOnly"

Those are the two things that are set on a CheckBox that are not set on a TextView.

Upvotes: 2

Code-Apprentice
Code-Apprentice

Reputation: 83557

According to the Android API docs (emphasis mine):

android:textAppearance

Base text color, typeface, size, and style.

Must be a reference to another resource, in the form "@[+][package:]type:name" or to a theme attribute in the form "?[package:][type:]name".

This corresponds to the global attribute resource symbol textAppearance.

This suggests that you just need to reference the same resource in the android:textAppearance attributes for your TextViews that you use in your RadioButtons.

Upvotes: -1

Related Questions