Android?MaterialAlertDialogBuilder修改按鈕屬性
編寫按鈕屬性
首先再values/themes 或者values/style在文件下編寫按鈕屬性

buttonBarPositiveButtonStyle對應(yīng)著確認(rèn)按鈕
buttonBarNegativeButtonStyle對應(yīng)著取消按鈕
<style name="AlertDialogTheme">
<item name="buttonBarPositiveButtonStyle">@style/Alert.Button.Positive</item>
<item name="buttonBarNegativeButtonStyle">@style/Alert.Button.Negative</item>
</style>
<style name="Alert.Button.Positive" parent="Widget.MaterialComponents.Button.TextButton">
<item name="backgroundTint">@color/colorPrimary</item>
<item name="rippleColor">@color/colorAccent</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:textSize">14sp</item>
<item name="android:textAllCaps">false</item>
<item name="android:layout_marginStart">3dp</item>
</style>
<style name="Alert.Button.Negative" parent="Widget.MaterialComponents.Button.TextButton">
<item name="backgroundTint">@color/colorPrimary</item>
<item name="rippleColor">@color/colorAccent</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:textSize">14sp</item>
</style>
Dialog 風(fēng)格設(shè)置
為Dialog設(shè)置風(fēng)格 new MaterialAlertDialogBuilder(getContext(), R.style.AlertDialogTheme)
AlertDialog.Builder alertDialogBuilder = new MaterialAlertDialogBuilder(getContext(), R.style.AlertDialogTheme)
.setTitle("添加設(shè)備")
.setPositiveButton(
"確定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
}
})
.setNegativeButton("取消", null);
alertDialogBuilder.show();
效果圖

buttonBarPositiveButtonStyle對應(yīng)著確認(rèn)按鈕
以上就是Android MaterialAlertDialogBuilder 修改按鈕屬性的詳細(xì)內(nèi)容,更多關(guān)于Android MaterialAlertDialogBuilder的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
Android使用Walle實現(xiàn)多渠道打包功能的實現(xiàn)示例
這篇文章主要介紹了Android使用Walle實現(xiàn)多渠道打包功能的實現(xiàn)示例,幫助大家更好的理解和學(xué)習(xí)使用Android開發(fā),感興趣的朋友可以了解下2021-04-04
Android自帶倒計時控件Chronometer使用方法詳解
這篇文章主要為大家詳細(xì)介紹了Android自帶倒計時控件Chronometer的使用方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-11-11
Android中使用GridView實現(xiàn)仿微信圖片上傳功能(附源代碼)
由于工作要求最近在使用GridView完成圖片的批量上傳功能,我的例子當(dāng)中包含仿微信圖片上傳、拍照、本地選擇、相片裁剪等功能,如果有需要的朋友可以看一下2017-08-08
修改Android Studio 的 Logcat 緩沖區(qū)大小操作
這篇文章主要介紹了修改Android Studio 的 Logcat 緩沖區(qū)大小操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-04-04
Android 中Fragment與Activity通訊的詳解
這篇文章主要介紹了Android 中Fragment與Activity通訊的詳解的相關(guān)資料,希望通過本文能幫助到大家,讓大家理解掌握如何通信的,需要的朋友可以參考下2017-10-10

