Android material design buttons - Pre lollipop

后端 未结 8 2064

How do I implement the \"raised button\" and the \"flat button\" as described in google\'s material design guidelines?


Raised buttons add dimension

8条回答
  •  逝去的感伤
    2021-01-29 20:22

    This requires Android 5.0

    Raised Button

    Inherit your button style from Widget.Material.Button, and the standard elevation and raising action will automatically be applied.

    
    

    Then you need to create a raised_button_background.xml file with your button's background color inside a ripple tag:

    
        
    
    

    Flat Button

    Edit: Instead of my previous advice for flat buttons, you should instead use follow the advice given by Stephen Kaiser below:

    Edit: If you are using Support Library, you can achieve the same result on Pre-Lollipop devices by using style="?attr/borderlessButtonStyle". (notice the absence of android:) The above example then becomes

提交回复
热议问题