I wrote one style for TextView, and I set it for my TextViewhow style="@style/popup_window_text_style", working fine, no problem.
Now I want the same style to be executed programmatically for my text view
TextView textView = new TextView(mContext);
Is there a way to do this programmatically in Java?
My style in styles.xml
<style name="popup_window_text_style">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:minWidth">60dp</item>
<item name="android:padding">10dp</item>
<item name="android:layout_marginLeft">1dp</item>
<item name="android:layout_marginRight">1dp</item>
<item name="android:background">@drawable/ctxmenu_btn_selector</item>
<item name="android:textColor">@android:color/black</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">16sp</item>
<item name="android:gravity">center_vertical</item>
<item name="android:singleLine">true</item>
</style>
source
share