create different color strike through

后端 未结 3 467
死守一世寂寞
死守一世寂寞 2020-12-20 02:27

I am trying to create textview with text color as black and strikthrough as red, I tried to use html but does not seems to work

String styledText = \"

        
3条回答
  •  温柔的废话
    2020-12-20 02:42

    late to the party but use a layer-list and place it on top of the textview background. works perfectly. Let me show you.

    create in the drawables folder a file called strikethru.xml:

     
    
        
            
                
            
        
        
            
                 
            
        
    
    

    then in your textview do this:

        
    

    the padding right of 3dp makes the strike through come out more from the text to give a real world effect.

提交回复
热议问题