What is the equivalent of “android:fontFamily=”sans-serif-light" in Java code?

后端 未结 6 1793
半阙折子戏
半阙折子戏 2020-12-23 15:46

My question is quite simple:

In every of my textview, I am currently using the attribute

android:fontFamily=\"sans-serif-light\"

6条回答
  •  北海茫月
    2020-12-23 16:25

    In my opinion there is still a way to apply system fonts programatically on TextView without having any memory issue and that is using textview.setTextAppearance method :

    
    
    
    
    if(condition){
        textView.setTextAppearance(context,R.style.styleA);
    }else{
        textView.setTextAppearance(context,R.style.styleB);
    }
    

提交回复
热议问题