我試圖設計一個AlertDialog來取悅客戶。他們喜歡 Theme.Holo.Light.Dialog上的藍色標題欄,但喜歡另一主題的綠色複選框。 這是我想生產什麼:對話框複選框上的自定義樣式
所以,我已經有了一個樣式定義是這樣的:
<style name="MyDialogTheme" parent="@android:Theme.Holo.Light.Dialog">
<item name="android:listChoiceIndicatorMultiple">@drawable/checkbox_green</item>
</style>
<style name="mycheckbox" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/checkbox_box</item>
</style>
,我已經得到了checkbox_green的定義如下這是隻是PNG文件:
<item android:state_checked="false"
android:drawable="@drawable/checkbox_unchecked" />
<item android:state_checked="true"
android:drawable="@drawable/checkbox_checked"/>
</selector>
和創建我的對話建設者用特異性IC主題在Java中,像這樣:
ContextThemeWrapper ctw = new ContextThemeWrapper(mContext, R.style.MyDialogTheme);
AlertDialog.Builder builder= new AlertDialog.Builder(ctw);
但我不能得到這個主題,以顯示綠色複選框,而不是藍色的對話框。 我得到這個:
我會繼續前進,創造一個完整的佈局,然後使用這樣的:
AlertDialog shareDialog = new AlertDialog.Builder(mContext).create();
LayoutInflater inflater = MainActivity.this.getLayoutInflater();
View dialogView = null;
dialogView = inflater.inflate(R.layout.share, (ViewGroup) getCurrentFocus());
shareDialog.setView(dialogView);
但是這需要所有樣式對話框,而不僅僅是checkboxes.It似乎如此簡單的重新設計複選框的風格,但我無法做到這一點。
除了創建一個完整的佈局和用於獲取綠色複選框而不是藍色,我必須做什麼?
是的,我已經這樣做了,但需要創建一個整體佈局來容納複選框,而不是簡單地重新設計那些對話框將要構建的樣式 – Martin
我想你想要改變內置樣式複選框rahter比創造新的... mi好 –
我想這會幫助...有些人提供了我這個...希望它也適用於你... http://android-holo-colors.com/ –