相关疑难解决方法(0)

如何更改AlertDialog的主题

我想知道是否有人可以帮助我.我正在尝试创建自定义AlertDialog.为此,我在styles.xml中添加了以下代码行

<resources>
 <style name="CustomAlertDialog" parent="android:Theme.Dialog.Alert">
  <item name="android:windowBackground">@drawable/color_panel_background</item>
 </style>
</resources>
Run Code Online (Sandbox Code Playgroud)
  • color_panel_background.9.png位于drawable文件夹中.这也可以在Android SDK res文件夹中找到.

以下是主要活动.

package com.customdialog;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;

public class CustomDialog extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        this.setTheme(R.style.CustomAlertDialog);
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage("HELLO!");
        builder .setCancelable(false)
          .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int id) {
               //MyActivity.this.finish();
           }
       })
       .setNegativeButton("No", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int …
Run Code Online (Sandbox Code Playgroud)

alert android themes dialog

230
推荐指数
9
解决办法
33万
查看次数

如何使用appCompat 22.1及更高版本的新AlertDialog并设置其样式

我正在尝试从默认的android迁移AlertDialog到appCompat-22.1中包含的新的android 到目前为止我了解你只需导入android.support.v7.app.AlertDialog包以便使用它.

但我怎么样呢呢?例如,更改正/负按钮颜色,标题颜色,消息颜色和背景颜色?

android android-appcompat android-alertdialog android-support-library

149
推荐指数
4
解决办法
13万
查看次数

如何更改AlertDialog标题的颜色以及其下方的线条颜色

我使用此命令更改了AlertDialog标题的颜色

alert.setTitle( Html.fromHtml("<font color='#FF7F27'>Set IP Address</font>"));
Run Code Online (Sandbox Code Playgroud)

但我想改变标题下出现的线条的颜色; 我怎样才能做到这一点 ?

注意:我不想使用自定义布局

所需效果的屏幕截图

android android-alertdialog

107
推荐指数
5
解决办法
13万
查看次数

AlertDialog样式 - 如何更改标题,消息等的样式(颜色)

我已经突破了这个问题.我需要做的是,AlertDialog在我的Android应用程序中更改所有s 的样式- 对话框背景需要是white-ish,文本需要是black-ish.我尝试创建了很多样式,主题,并从代码,清单等应用,但没有成功,关于内部的文本颜色AlertDialog.现在,我有最简单的代码,设置如下:

表现:

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
Run Code Online (Sandbox Code Playgroud)

styles.xml:

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:alertDialogStyle">@style/DialogStyle</item>
</style>

<style name="DialogStyle" parent="@android:style/Theme.Dialog">
    <!-- changing these background stuff works fine -->
    <item name="android:bottomBright">@android:color/white</item>
    <item name="android:bottomDark">@android:color/white</item>
    <item name="android:bottomMedium">@drawable/dialog_footer_bg</item>
    <item name="android:centerBright">@android:color/white</item>
    <item name="android:centerDark">@drawable/dialog_body_bg</item>
    <item name="android:centerMedium">@android:color/white</item>
    <item name="android:fullBright">@color/orange</item>
    <item name="android:fullDark">@color/orange</item>
    <item name="android:topBright">@color/green</item>
    <item name="android:topDark">@drawable/dialog_header_bg</item>
Run Code Online (Sandbox Code Playgroud)

下面列出的项目不起作用(请阅读我在每个元素上面的评论):

    <!-- panelBackground is not getting set to null, there is something squarish around it -->
    <item name="android:panelBackground">@null</item>

    <!-- Setting this textColor doesn't seem to have any effect at …
Run Code Online (Sandbox Code Playgroud)

android android-theme android-alertdialog android-styles

40
推荐指数
5
解决办法
10万
查看次数