Is there an easy way to add a border to the top and bottom of an Android View?

后端 未结 24 2386
盖世英雄少女心
盖世英雄少女心 2020-11-22 13:36

I have a TextView and I\'d like to add a black border along its top and bottom borders. I tried adding android:drawableTop and android:drawableBottom

24条回答
  •  情歌与酒
    2020-11-22 14:15

    So I wanted to do something slightly different: a border on the bottom ONLY, to simulate a ListView divider. I modified Piet Delport's answer and got this:

    
    
       
          
                    
    
            
       
    
        
        
              
                
                
            
       
    
    
    

    Note using px instead of dp to get exactly 1 pixel divider (some phone DPIs will make a 1dp line disappear).

提交回复
热议问题