Set style for TextView programmatically

后端 未结 12 1799
南方客
南方客 2020-11-22 09:47

I\'m trying to use the TextView constructor with style like this:

TextView myText = new TextView(MyActivity.this, null, R.style.my_style);
         


        
12条回答
  •  独厮守ぢ
    2020-11-22 10:23

    You can set the style in the constructor (but styles can not be dynamically changed/set).

    View(Context, AttributeSet, int) (the int is an attribute in the current theme that contains a reference to a style)

    Answer from Romain Guy

    reference

提交回复
热议问题