Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/194.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android ImageView没有';t填充其布局的高度_Android_Android Listview - Fatal编程技术网

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