gpt4 book ai didi

android - AlertDialog背景颜色问题

转载 作者:行者123 更新时间:2023-12-02 14:26:21 27 4
gpt4 key购买 nike

我有一个 Android AlertDialog XML 布局,为了获得更好的可见性,将背景设置为白色,将 textColor 设置为黑色。在我删除 android:text="Hello World"条目并尝试将 Java 中的 setMessage 设置为有意义的内容之前,此方法工作正常。有意义的消息被设置并显示得很好,但我失去了带有黑色文本的白色背景......任何人都可以帮助解释这里发生了什么(开始拉我的头发!)?我已包含以下代码。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollview_1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white">
<LinearLayout
android:id="@+id/layout_root"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp">
<TextView android:id="@+id/help_text"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Hello World"
android:textSize="20sp"
android:textColor="@color/black">
</TextView>
</LinearLayout>

private AlertDialog showHelp() {

AlertDialog alertDialog = new AlertDialog.Builder(Game.this).create();
View diagview = LayoutInflater.from(getBaseContext()).inflate(R.layout.help_dialog,
(ViewGroup) findViewById(R.id.layout_root));
alertDialog.setTitle("Help...");
alertDialog.setView(diagview);
alertDialog.setIcon(R.drawable.ic_help);
alertDialog.setMessage(this.getString(help[helpIndex]));
alertDialog.setIcon(R.drawable.ic_help);
alertDialog.setButton("Close", new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int which) {
} });

alertDialog.show();
return alertDialog;
}

最佳答案

How to change dialog background color programmatically?有答案了。

您必须扩展布局类才能使用自定义主题,如本教程中所述: http://blog.androgames.net/10/custom-android-dialog/

关于android - AlertDialog背景颜色问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5995066/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com