android – 如何在AlertDialog.Builder AppCompat中更改Items的颜色?
作者:互联网
如何在AlertDialog.Builder AppCompat中更改Items的颜色?
我想将textColor项目(照片,gallary)设置为其他任何项目.
这是我的代码:
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AppCompatAlertDialogStyle);
builder.setTitle(getResources().getString(R.string.choose_image_source));
builder.setItems(new CharSequence[]{getResources()
.getString(R.string.photo), getResources()
.getString(R.string.camera)}, new DialogInterface.OnClickListener() {
…
<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">#000000</item><!-- buttons OK cancel-->
<item name="android:textColorPrimary">#696969</item><!--text in message-->
<item name="android:background">#f0a400</item> <!-- all bg-->
</style>
<style name="MyTitleTextStyle">
<item name="android:textColor">#000000</item><!-- title color-->
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Title</item>
</style>
解决方法:
试试这个:
<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">#000000</item><!-- buttons OK cancel-->
<item name="android:textColorPrimary">#696969</item><!--text in message-->
<item name="android:background">#f0a400</item> <!-- all bg-->
<!-- items color -->
<item name="textColorAlertDialogListItem">#33b5e5</item>
</style>
<style name="MyTitleTextStyle">
<item name="android:textColor">#000000</item><!-- title color-->
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Title</item>
</style>
标签:android,text,colors,alertdialog,android-appcompat 来源: https://codeday.me/bug/20190829/1763241.html