如果我设置活动主题,那么该活动的弹出窗口不应该改变,这可能吗?

时间:2017-02-02 11:01:09

标签: android android-activity alertdialog

在启动我的应用时,会出现空白屏幕,因为解析此主题已设为android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"

但此活动的警报对话框也会发生变化。 我不想改变对话的主题。 我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

如果您想使用默认主题,请按以下方式创建对话框:

logout(token) {
  return remove(
    this.host,
    END_POINTS.DELETE_TOKEN,
    {
      pathParams: { token },
    },
    {
      Accept: 'application/json',
      'Content-Type': 'application/json',
      Authorization: `Bearer ${token}`,
    },
  );
}

如果您想进一步更改AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, android.R.style.Theme_Dialog)); 在xml中创建自定义样式

Dialog

然后创建对话框:

<style name="CustomDialog" parent="@style/Theme.AppCompat.Dialog">
   // insert your custom attributes
</style>

您可以使用AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this,R.style.CustomDialog)); 中的DialogFragment内的setStyle(STYLE_NORMAL, R.style.CustomDialog);内的样式