Android?MaterialAlertDialogBuilder修改按鈕屬性
編寫按鈕屬性
首先再values/themes 或者values/style在文件下編寫按鈕屬性
buttonBarPositiveButtonStyle
對(duì)應(yīng)著確認(rèn)按鈕
buttonBarNegativeButtonStyle
對(duì)應(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
對(duì)應(yīng)著確認(rèn)按鈕
以上就是Android MaterialAlertDialogBuilder 修改按鈕屬性的詳細(xì)內(nèi)容,更多關(guān)于Android MaterialAlertDialogBuilder的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
iOS UIButton 點(diǎn)擊無(wú)響應(yīng)的解決辦法
在開發(fā)中按鈕我們經(jīng)常會(huì)遇到,但是有時(shí)候會(huì)碰到一些難以處理的問(wèn)題,就是按鈕點(diǎn)擊無(wú)響應(yīng),其實(shí)解決方法也不難。下面小編之家小編抽空給大家介紹iOS UIButton 點(diǎn)擊無(wú)響應(yīng)的解決辦法,需要的朋友參考下吧2017-12-12Android使用Walle實(shí)現(xiàn)多渠道打包功能的實(shí)現(xiàn)示例
這篇文章主要介紹了Android使用Walle實(shí)現(xiàn)多渠道打包功能的實(shí)現(xiàn)示例,幫助大家更好的理解和學(xué)習(xí)使用Android開發(fā),感興趣的朋友可以了解下2021-04-04Android自帶倒計(jì)時(shí)控件Chronometer使用方法詳解
這篇文章主要為大家詳細(xì)介紹了Android自帶倒計(jì)時(shí)控件Chronometer的使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-11-11Android中使用GridView實(shí)現(xiàn)仿微信圖片上傳功能(附源代碼)
由于工作要求最近在使用GridView完成圖片的批量上傳功能,我的例子當(dāng)中包含仿微信圖片上傳、拍照、本地選擇、相片裁剪等功能,如果有需要的朋友可以看一下2017-08-08修改Android Studio 的 Logcat 緩沖區(qū)大小操作
這篇文章主要介紹了修改Android Studio 的 Logcat 緩沖區(qū)大小操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-04-04Kotlin利用Regex如何構(gòu)建正則表達(dá)式詳解
正則表達(dá)式,又稱規(guī)則表達(dá)式。下面這篇文章主要給大家介紹了關(guān)于Kotlin利用Regex構(gòu)建正則表達(dá)式的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起看看吧。2017-12-12Android 中Fragment與Activity通訊的詳解
這篇文章主要介紹了Android 中Fragment與Activity通訊的詳解的相關(guān)資料,希望通過(guò)本文能幫助到大家,讓大家理解掌握如何通信的,需要的朋友可以參考下2017-10-10Android自定義view繪制圓環(huán)占比動(dòng)畫
這篇文章主要為大家詳細(xì)介紹了Android自定義view繪制圓環(huán)占比動(dòng)畫,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-01-01