隐藏自定义对话框的主要布局

时间:2011-08-24 10:19:18

标签: android

我已经为自定义对话框做了布局,它里面有两个imageview。我想在出现对话框时显示两个Imageview。我想隐藏我的xml文件的主要布局我使用“#00000000”作为背景:颜色,但它不起作用。 有没有办法做同样的事情?

感谢。

这是我的布局。我拍过截屏请看看我想隐藏图片中显示的边框。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="fill_parent" android:layout_width="fill_parent"
    android:orientation="vertical" android:background="#00000000">
    <LinearLayout android:id="@+id/linearLayout1"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content">
        <ImageView android:id="@+id/img_closeimage" android:src="@drawable/product_zoom_close"
                android:layout_width="wrap_content" android:layout_height="wrap_content"
                android:clickable="true"></ImageView>

    </LinearLayout>
    <LinearLayout android:id="@+id/linearLayout2"
        android:layout_marginLeft="25dip" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginTop="-5dip" android:layout_marginBottom="20dip" android:layout_marginRight="20dip">
        <ImageView android:id="@+id/img_ProductZoom" android:src="@drawable/index"
                android:layout_width="wrap_content" android:layout_height="wrap_content"
                 ></ImageView>

    </LinearLayout>
</LinearLayout>

image description here

1 个答案:

答案 0 :(得分:1)

Adinias评论是正确的,您的布局有一些冗余。您还说您只想显示图像视图,但您的布局包含两个图像视图。如果您只想显示一个图像视图,那么您的布局应如下所示:

<?xml version="1.0" encoding="utf-8"?>
<ImageView android:id="@+id/img_ProductZoom" android:src="@drawable/index"
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    />

如果要显示两个ImageView,请使用:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="fill_parent" android:layout_width="fill_parent"
    android:orientation="vertical" android:background="#00000000">
    <ImageView android:id="@+id/img_closeimage" android:src="@drawable/product_zoom_close"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:clickable="true"/>
    <ImageView android:id="@+id/img_ProductZoom" android:src="@drawable/index"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        />
</LinearLayout>

您当前的布局看起来就像它一样,因为您已指定布局以使用android:layout_height="fill_parent"android:layout_width="fill_parent"占用尽可能多的空间。请尝试使用wrap_content作为高度和宽度。