Create TextView ( in the code ) with style but without attributes
Howdy, I am currently generating some textviews in a loop. It would be great if I could apply a style to those textviews.
This style already containts all attributes so I w开发者_开发知识库ould not neet to set a Attribute, however if I do this
TextView counterTV = new TextView(activity,null, R.style.MenuField);
the TextView is created but there is are no styles applied to it :(.
It works flawlessly if I apply the same style to a textview in a XML File.
Try this little beauty:
TextView counterTV = new TextView(activity);
counterTV.setTextAppearance(activity, R.style.MenuField);
I have used it to apply the standard Android styles (like android.R.style.TextAppearance_Large
) to TextView
s before.
Have you tried setting the Layout Params?
精彩评论