我试图设计一个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/ –