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

标签 android android-layout custom-component dialog

出于学习目的,我在 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/

相关文章:

Android:允许 TableLayout 中的边距/填充以在小部件之间进行一些分隔

android - 关于 Spinner INVALID_POSITION 的基本查询

delphi - 自定义属性编辑器 - 它们似乎从未出现

android - NFC 读/写 flutter

android - Espresso : how to click one of image in listview?

android - 渲染问题 渲染期间引发异常 : Could not find layout resource

css - 使用 CSS2/3、mixins 和绘图 API/HTML5 canvas 的 OpenLaszlo 现代组件集

c++ - 在设计时限制组件的大小

android - 来自 InputStream 的 Drawables 随 ViewFlipper 改变

android - Artifactory 使用资源发布 Android 库