相关疑难解决方法(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万
查看次数

通过样式更改Android Dialog按钮文本大小

我试图通过样式扩大我的所有应用程序对话框按钮上的文本大小.以下代码将更改按钮背景颜色甚至文本大小写,但由于某种原因,textSize项目不符合:

<style name="MyAppTheme" parent="@android:style/Theme.Holo">
    <item name="android:dialogTheme">@style/MyApp.Dialog</item>
    <item name="android:alertDialogTheme">@style/MyApp.Dialog.Alert</item>
</style>

<style name="MyApp.Dialog" parent="@android:style/Theme.Holo.Dialog">
    <item name="android:borderlessButtonStyle">@style/MyApp.BorderlessButton</item>
</style>

<style name="MyApp.Dialog.Alert" parent="@style/MyApp.Dialog">
    <item name="android:windowBackground">@android:color/transparent</item>
</style>

<style name="MyApp.BorderlessButton" parent="@android:style/Widget.Holo.Button.Borderless">
    <item name="android:textSize">50sp</item>
    <item name="android:textAllCaps">true</item>
    <item name="android:background">#800</item>
</style>
Run Code Online (Sandbox Code Playgroud)

带有背景颜色和textAllCaps但没有文字大小的对话框按钮

为什么没有读取textSize?我需要做些什么来扩大它?

android android-layout android-theme android-dialog android-styles

11
推荐指数
2
解决办法
1万
查看次数

如何减少AlertDialog.Builder标题字体大小和正按钮大小?

是否可以减少AlertDialog.Builder标题字体大小和正按钮大小?如果有,请让我该怎么办?

android android-alertdialog

0
推荐指数
1
解决办法
8850
查看次数