2013-08-22 65 views
0

在我的屏幕上,我有一个图像视图与一个小图像。我希望用户在点击它时看到全尺寸图像。所以我想我会制作一个可自定义布局的可取消对话框,只有ImageView。所以我创造了这个布局:Android对话框自定义布局

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" > 

<ImageView 
    android:id="@+id/img_product_full" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:contentDescription="@string/desc_full_product_image" 
    android:scaleType="fitCenter" /> 

</LinearLayout> 

的问题是,即使我已经标记每个尺寸"wrap_content"我仍然看到的形象和对话边界之间有一些差距。我试图设置padding:"0dp",将minHeight和minWidth设置为0dp,但无济于事,我仍然看到了这个差距。 那么我该如何摆脱这种差距呢?我怎样才能使对话边框与图像边界相邻?

回答

0
<ImageView android:id="@+id/img_product_full" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:contentDescription="@string/desc_full_product_image" 
     android:scaleType="fitXY" 
     android:adjustViewBounds="true" /> 

fitXY/adjustViewBounds属性应该解决这个问题。

+0

我试过了,但它延伸并扰乱了图像。 – Igal

+0

android:adjustViewBounds =“true”将是我的下一个猜测 –

+0

太棒了,它的工作!非常感谢你! – Igal

相关问题