gpt4 book ai didi

android - 设置背景图片提醒对话框

转载 作者:搜寻专家 更新时间:2023-11-01 09:00:21 26 4
gpt4 key购买 nike

我正在尝试使用 ButtonsRadioGroup 创建自定义的 AlertDialog。我想为这个 AlertDialog 在我的 drawable 中保存一个背景图像。

AlertDialog.Builder alert = new AlertDialog.Builder(AutoGenerate.this);                    
alert.setTitle("Select color");

是否有任何替代选项,如 alert.setbackgrounddrawable(R.drawable.img)

最佳答案

您可以使用布局文件来做到这一点。检查下面的代码

LayoutInflater inflater = (LayoutInflater) this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dialoglayout = inflater.inflate(R.layout.dialog_layout, null);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(dialoglayout);
builder.show();

对话框布局.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:orientation="vertical" >

<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/ic_launcher" />

</LinearLayout>

您还可以在 xml 中使用不同的 View 。

关于android - 设置背景图片提醒对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15520086/

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