Rah*_*san 4 alert android dialog android-alertdialog android-styles
干草,
有没有一种简单的方法可以在不改变整个应用程序title的text原色的情况下更改 和 颜色?
这是我现在得到的:
我不想改变 textColorPrimary
首先,创建一个这样的样式定义:
<style name="DialogTheme" parent="ThemeOverlay.AppCompat.Dialog">
<item name="android:textColorPrimary">your color here</item>
</style>
Run Code Online (Sandbox Code Playgroud)
然后,当您创建对话框时,不要使用AlertDialog.Builder(Context)构造函数,而是使用该AlertDialog.Builder(Context, int)方法并传递对您的样式的引用:
new AlertDialog.Builder(this, R.style.DialogTheme)
.setTitle("Hello world")
.setMessage("some longer text for the body of the dialog")
.show();
Run Code Online (Sandbox Code Playgroud)
尽管这取决于更改textColorPrimary,但它不会以影响您应用程序中其他任何内容的方式这样做。
| 归档时间: |
|
| 查看次数: |
4521 次 |
| 最近记录: |