Widget_AppCompat_Button_ButtonBar_AlertDialog的用法
时间: 2023-07-22 07:10:17 浏览: 59
Widget_AppCompat_Button_ButtonBar_AlertDialog是一个AppCompat主题下的按钮样式,它通常用于Alert Dialog的按钮。在使用这个样式时,你需要将它应用于你的按钮布局中的Button或AppCompatButton控件。
以下是一个使用Widget_AppCompat_Button_ButtonBar_AlertDialog样式的AlertDialog示例:
```xml
<androidx.appcompat.app.AlertDialog
android:id="@+id/alert_dialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:title="Alert Dialog">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="This is an example of an Alert Dialog." />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/positive_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="OK"
style="@style/Widget.AppCompat.Button.ButtonBar.AlertDialog" />
<Button
android:id="@+id/negative_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel"
style="@style/Widget.AppCompat.Button.ButtonBar.AlertDialog" />
</LinearLayout>
</androidx.appcompat.app.AlertDialog>
```
在这个示例中,我们使用了AppCompat主题下的AlertDialog,并在其中添加了两个使用Widget_AppCompat_Button_ButtonBar_AlertDialog样式的按钮。这些按钮将具有AppCompat主题下的Alert Dialog按钮样式,以使AlertDialog看起来更加一致。
希望这个例子可以帮助你了解Widget_AppCompat_Button_ButtonBar_AlertDialog的用法。
相关推荐
![jar](https://img-home.csdnimg.cn/images/20210720083455.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![dart](https://img-home.csdnimg.cn/images/20210720083646.png)