2011-08-24 75 views
0

我为自定义对话框进行了布局,它内部有两个图像视图。我想在出现对话框时显示两个Imageview。并且我想隐藏我使用“#00000000”作为背景的xml文件的主布局:color,但它不起作用。 有没有办法做同样的事情?隐藏自定义对话框的主布局

谢谢。

这是我的布局。我已经拍摄了屏幕快照,请看看我想隐藏图片中显示的边框。

<?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

+0

您的自定义布局看起来很奇怪;为什么在主Linearlayout中有两个嵌入的LinearLayout(即使使用相同的id @ @ id/linearLayout1!!),每个都带有一个ImageView,如果您只需要一个ImageView用于该对话框? – Adinia

回答

1

Adinias评论是正确的,你的布局有相当一定的冗余度。你也说你只想显示一个imageview,但你的布局包含两个图像浏览。如果你只是想显示一个ImageView的,那么你的布局应该是这样的:

<?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" 
    /> 

如果你想显示两个ImageViews,使用此:

<?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代替高度和宽度。

+0

请参阅图像说明我必须显示图像和关闭按钮,如图像说明中所示。以及由于获得预期结果而产生的冗余。使用上面的代码,它不会显示预期的视图。谢谢 – Himanshu

+0

它无法将布局大小更改为wrap_content? – pgsandstrom