Reputation: 93
I create simple style.xml
file
<style name="You.EditText.Style" parent="@android:style/Widget.EditText">
<item name="android:textColor">@color/colorRed</item>
<item name="android:gravity">center</item>
</style>
But all EditText
s I create dynamically. How I can declare my style to EditText
attribute?
Upvotes: 2
Views: 173
Reputation: 25584
Instantiate your EditText
view like this:
EditText e = new EditText(context, null, R.style.You_EditText_Style);
Upvotes: 2
Reputation: 2298
You can do this with the EditText#setTextAppearance(context, resid) method.
Example:
myEditText.setTextAppearance(getApplicationContext(), R.style.id);
See EditText reference.
Upvotes: 0