我已将appCompat材质设计添加到我的应用程序中,似乎警报对话框未使用我的primary,primaryDark或强调颜色.
这是我的基本风格:
<style name="MaterialNavyTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/apptheme_color</item>
<item name="colorPrimaryDark">@color/apptheme_color_dark</item>
<item name="colorAccent">@color/apptheme_color</item>
<item name="android:textColorPrimary">@color/action_bar_gray</item>
</style>
Run Code Online (Sandbox Code Playgroud)
根据我的理解,对话框按钮文本也应该使用这些颜色.我的理解是错的还是我还需要做些什么?
解:
明确的答案让我走上正轨.
<style name="MaterialNavyTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/apptheme_color</item>
<item name="colorPrimaryDark">@color/apptheme_color_dark</item>
<item name="colorAccent">@color/apptheme_color</item>
<item name="android:actionModeBackground">@color/apptheme_color_dark</item>
<item name="android:textColorPrimary">@color/action_bar_gray</item>
<item name="sdlDialogStyle">@style/DialogStyleLight</item>
<item name="android:seekBarStyle">@style/SeekBarNavyTheme</item>
</style>
<style name="StyledDialog" parent="Theme.AppCompat.Light.Dialog">
<item name="colorPrimary">@color/apptheme_color</item>
<item name="colorPrimaryDark">@color/apptheme_color_dark</item>
<item name="colorAccent">@color/apptheme_color</item>
</style>
Run Code Online (Sandbox Code Playgroud) android android-appcompat android-support-library material-design material-components-android
最近我从支持库切换到com.google.android.material:material:1.0.0
但是现在我有一个问题,在这个页面上有一个注释https://github.com/material-components/material-components-android/blob/master/docs/getting-started.md
注意:使用"材质成分"主题可启用自定义视图填充程序,该填充程序将使用"材质"对应项替换默认组件.目前,这仅使用MaterialButton替换Button XML组件.
我正在使用的主题
Theme.MaterialComponents.Light.NoActionBar
Run Code Online (Sandbox Code Playgroud)
它完全按照它在说明中所说的,它将AlertDialog按钮替换为MaterialButtons,但问题是默认情况下MaterialButtons是彩色背景,现在按钮看起来像这样: 
我怎样才能让它们再次无边界和无背景?
PS我正在使用警报构建器来创建警报对话框:
android.app.AlertDialog.Builder
Run Code Online (Sandbox Code Playgroud) android android-alertdialog android-styles material-design material-components-android
我有一个弹出窗口,可以在我的应用程序中下载音频指令.我想要做的是我想将"OK"的默认文本颜色更改为蓝色.我试了一下,但它不起作用.这是我的代码:
private void showDownloadPgmPopup() {
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(getActivity());
builder.setTitle("Download instructional audio?");
builder.setMessage(ParamConstants.AUDIODOWNLOADPERMISSION);
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
WwDatabaseHelper.storeSelectedWeekAndDay(getActivity(), mSelectedWeekDataModel);
goToMoveScreen();
}
});
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
AndroidDownloadFileByProgressBarActivity.StartAudioAssetDownload(getActivity());
}
}).create();
// change the text color of download instruction ok button
final android.app.AlertDialog dialog = builder.show();
dialog.setOnShowListener( new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface arg0) {
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(Color.parseColor("#ff5722"));
}
});
dialog.setCanceledOnTouchOutside(false);
dialog.show();
}
Run Code Online (Sandbox Code Playgroud)
但这种变化并没有反映任何人都可以告诉我我做错了什么?