banded background with two colors?

后端 未结 5 820
梦如初夏
梦如初夏 2020-12-03 11:00

I am trying to create a bottom bar with the background like this :

\"enter

I a

5条回答
  •  悲&欢浪女
    2020-12-03 11:45

    As others pointed out, a ninepatch would be ideal in this situation (and won't take much memory). Working around with XML is not optimal. Here is something you can try:

    
        
            
                
                
            
        
    
        
            
                
                
            
        
    
    

    in this case your view is considered beeing 40dp high

    It's a layer list with two blocks in different colors. The problem with the XML approach is that you can't adjust the height of the blocks to a percentage (=50%). You have to use half of the actual view size in dp. Which means you have to adjust this drawable each time you change your view height/layout. A ninepatch would adjust to this automatically.

提交回复
热议问题