Android 自动设置ImageView和按钮的高度
我正在尝试设置图像视图和按钮的高度,以便为不同的设备自动调整大小。我想显示imageview下面的按钮,无论图像的高度如何 我正在尝试以下代码:Android 自动设置ImageView和按钮的高度,android,android-imageview,Android,Android Imageview,我正在尝试设置图像视图和按钮的高度,以便为不同的设备自动调整大小。我想显示imageview下面的按钮,无论图像的高度如何 我正在尝试以下代码: <ImageView android:id="@+id/imageView" android:layout_width="match_parent" android:layout_height="match_parent" /> <Button android
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="@+id/send_btn"
android:layout_bellow="imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
提前感谢您,我想您正在使用带有android:oriention=“vertical”的LinerLayout。 我将使用布局权重属性,如下所示:
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:id="@+id/send_btn"
android:layout_bellow="imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
它将自动用图像视图填充所有上部
通过在ImageView中使用layout\u weight=“1”和layout\u height=“wrap\u content”,您可以告诉Android ImageView是“重要的”并且必须填充所有剩余空间。它应该适合屏幕或滚动很好它应该适合下面的屏幕答案可以将缩放类型添加到中心裁剪如果图像更大,它可以很好地帮助工作,但分辨率发生了变化,我如何解决这个问题?您可能需要将其添加到imageview:android:adjustViewBounds=“true”android:scaleType=“fitXY”我试图设置imageview:android:adjustViewBounds=“true”android:scaleType=“fitXY”但当我在图像视图中设置图片时,分辨率发生了变化