Set View style dynamically


Ask A Question





Login To post a question

I’m trying to dynamically create a TextView and then set a style which I previously defined in XML.

This is the XML which I defined in styles.xml:

<style name="box_area">
    <item name="android:layout_width">30dp</item>
    <item name="android:layout_height">30dp</item>
    <item name="android:background">@android:color/holo_red_dark</item>
</style>

Java Code:

TextView tv = new TextView(this, null, R.style.box_area);

I don’t know which is the reason, but the style is not being applied.
Thank you

For more info please click herehttps://stackoverflow.com/q/51811337



Have a question or need a custom quote?
info@smartinfocare.com