Android : set TextView style at runtime

前端 未结 5 1086
我在风中等你
我在风中等你 2020-12-09 18:44

Does any body know how to set style for TextView at run time:

something like this

myTextView.setStyle(R.style.mystyle);
5条回答
  •  天命终不由人
    2020-12-09 19:36

    I also still did not find (sadly) a way to change Style at runtime.

    If it is just about changing the checkbox appearance (as you mention in a comment of another answer), you can use this:

    myCheckbox.setButtonDrawable(R.drawable.star_checkbox);
    

    And have a star_checkbox.xml file in the drawable directory describing the checkbox background according to its states such as:

    
    
        
    
        
    
        
    
        
    
    

    Also you need the corresponding png files in you drawable directory.

提交回复
热议问题