AlertDialog style buttons for an Activity

后端 未结 2 1158
没有蜡笔的小新
没有蜡笔的小新 2021-01-05 04:49

I have an activity with a Save and Cancel button at the bottom.

In AlertDialog, the buttons are displayed inside a styled container view of some sort.

How c

2条回答
  •  借酒劲吻你
    2021-01-05 05:53

    There are solutions given elsewhere that work. In short, you can simply use style attributes in your xml to achieve this. For instance, style="?android:attr/buttonBarStyle" and style="?android:attr/buttonBarButtonStyle" will do the job (for API 11+). Here is an example of two buttons horizontally put together.

    
    
        

    The only thing that remains, is that there is a horizontal line right above the buttons in an alertDialog, which the above code will not create. If you want to have that horizontal line, it should be added manually in the xml, above the LinearLayout. This will give you the horizontal line:

     
    

提交回复
热议问题