How to programmatically set style attribute in a view

前端 未结 11 2017
北恋
北恋 2020-11-22 06:38

I\'m getting a view from the XML with the code below:

Button view = (Button) LayoutInflater.from(this).inflate(R.layout.section_button, null);
11条回答
  •  长情又很酷
    2020-11-22 06:52

    If you are using the Support library, you could simply use

    TextViewCompat.setTextAppearance(textView, R.style.AppTheme_TextStyle_ButtonDefault_Whatever);
    

    for TextViews and Buttons. There are similar classes for the rest of Views :-)

提交回复
热议问题