2025-02-10

 

像列表這種選擇項的彈出式對話框,要改變樣式一般都采取重寫layout方式

 

今天才瞭解到 其實可以自定義樣式,與大傢分享下,其實很簡單

 

 

AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AlertDialogCustom)); 

 

 

然後自定義自己的樣式就可以瞭

 

<?xml version="1.0" encoding="utf-8"?> 

<resources> 

    <style name="AlertDialogCustom" parent="@android:style/AlertDialog"> 

        <item name="android:textColor">#00FF00</item> 

        <item name="android:typeface">monospace</item> 

        <item name="android:textSize">10sp</item> 

    </style> 

</resources>   

摘自:獨自登高樓 望斷天涯路

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *