gpt4 book ai didi

android - 自定义对话框背景图片在android中显示不清晰

转载 作者:行者123 更新时间:2023-11-29 15:22:01 27 4
gpt4 key购买 nike

出于学习目的,我在 android 中制作了一个简单的对话框 Activity ,并制作了一个自定义对话框并在另一个 Activity 中显示,一切进展顺利,唯一的问题是我放置的背景图像没有显示在整个对话框背景中..但是它还显示一个白色背景作为一个角,我在这里放了一个屏幕,这样我的问题就会清楚..!

我的形象:

enter image description here

我的代码是:

dialog.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00000000"
android:gravity="center"
android:orientation="vertical" >

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:background="@drawable/bg_dilog"
android:orientation="vertical" >

<ImageView
android:id="@+id/dialog_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/btn_close_38" />

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="20dp"
android:paddingLeft="30dp"
android:paddingRight="30dp" >

<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Login"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#202425" />

<Button
android:id="@+id/usernm"
android:layout_width="wrap_content"
android:layout_height="32dp"
android:layout_marginTop="5dp"
android:background="@drawable/text_box"
android:gravity="center"
android:hint="Please enter your client number"
android:textSize="12dp" />

<Button
android:id="@+id/pwd"
android:layout_width="wrap_content"
android:layout_height="31dp"
android:layout_marginTop="5dp"
android:background="@drawable/text_box"
android:gravity="center"
android:hint="Please password"
android:padding="5dp"
android:textSize="12dp" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:textColor="#6e6d6c"
android:layout_marginTop="7dp"
android:text="Remember me" />

<ImageView
android:id="@+id/chk_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:background="@drawable/checkbox"
android:textColor="#000000" />

</LinearLayout>

<Button
android:id="@+id/login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp"
android:background="@drawable/btn_small"
android:gravity="center"
android:text="Login"
android:textColor="#f6f1eb"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>

</LinearLayout>

最佳答案

尝试调用你的对话框构造函数:

getWindow().setBackgroundDrawableResource(android.R.color.transparent);

关于android - 自定义对话框背景图片在android中显示不清晰,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17358933/

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