Why button gets bigger when the background is set in android

前端 未结 6 861
心在旅途
心在旅途 2021-02-18 16:15

I encountered a problem with the Button view when I set a background to it using the android:background attribute in xml. Before I set the background,

6条回答
  •  忘掉有多难
    2021-02-18 16:45

    Another option if you want to support anything below API Level 21 is to create a custom drawable with a transparent stroke around a colored shape. This gives you the flexibility of also adding block colors and gradients.

    Note the stroke with and transparency which shrinks the button size

    button_background.xml

    
    
    
        
        
    
        
        
    
        
    
    

    Button

提交回复
热议问题