Android ImageView没有';t填充其布局的高度
我希望在Android ImageView没有';t填充其布局的高度,android,android-listview,Android,Android Listview,我希望在列表视图中添加一个图像视图。我想图像填充布局没有失真(基本上,填充高度和适应其宽度) 这就是我现在得到的: 我在ImageView中添加了灰色背景,使其更易于查看。红色是我想要的尺寸 这是我的密码: Project_form.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" a
列表视图
中添加一个图像视图
。我想图像填充布局没有失真(基本上,填充高度和适应其宽度)
这就是我现在得到的:
我在ImageView
中添加了灰色背景,使其更易于查看。红色是我想要的尺寸
这是我的密码:
Project_form.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/name_project"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:padding="3dp"
android:layout_alignParentLeft="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="25dp" >
</TextView>
<Button
android:id="@+id/button_project"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_custom"
android:layout_centerVertical="true"
android:focusable="false"
android:focusableInTouchMode="false"
android:layout_alignParentRight="true"
android:padding="3dp"
android:text=" details "
android:textSize="20dp"
android:visibility="invisible" />
<ImageView
android:id="@+id/imagesstep"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@color/grey"
android:adjustViewBounds="false"
android:layout_centerVertical="true"
android:padding="3dp"
android:layout_alignParentRight="true"
android:visibility="invisible" />
</RelativeLayout>
我试着使用不同的参数,比如ScaleType
、android:adjustViewBounds和layout\u width,但我的图像高度从未改变。我还尝试通过编程的方式(比如image.setMinHeight(parent.getHeight())来实现,但也失败了
有人能告诉我出了什么问题吗
非常感谢尝试将
布局高度的相对值更改为填充父项
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent">
<TextView ... />
<Button .. />
<ImageView ... />
</RelativeLayout>
从imageview中删除填充内容谢谢您的回答。将宽度和高度都设置为“?android:attr/listPreferredItemHeight”就成功了。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent">
<TextView ... />
<Button .. />
<ImageView ... />
</RelativeLayout>
<ImageView
...
android:minHeight="?android:attr/listPreferredItemHeight" />