Android对话框自定义布局
在我的屏幕上,我有一个带有小图像的图像视图。我希望用户在单击时看到完整大小的图像。所以我想我应该用自定义布局创建一个可取消的对话框,它只有ImageView。所以我创建了这个布局:Android对话框自定义布局,android,android-layout,dialog,android-dialog,Android,Android Layout,Dialog,Android Dialog,在我的屏幕上,我有一个带有小图像的图像视图。我希望用户在单击时看到完整大小的图像。所以我想我应该用自定义布局创建一个可取消的对话框,它只有ImageView。所以我创建了这个布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.androi
<?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\u content”
,我仍然看到图像和对话框边框之间存在一些间隙。我尝试设置填充:“0dp”
,将minHeight和minWidth设置为0dp,但没有效果,我仍然看到了该间隙。
那么,我怎样才能消除这种差距呢?如何使对话框边框与图像边框相邻?
<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属性应该可以解决这个问题。android:adjustViewBounds=“true”将是我的下一个猜测