layout:
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="A"
android:textSize="?normal_font_size"
/>
attrs.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="normal_font_size" format="dimension" />
</resources>
themes.xml :
<style name="MainTheme" parent="@android :style/Theme.Black.NoTitleBar">
<item name="normal_font_size">15px</item>
</style>
How to dynamically read the value of my theme defined in the code?
In your
attrs.xml, create a group of the values that you would like to read, you can even add a custom oneIn your code, you’ll be able to access this value via a
TypedArray