gpt4 book ai didi

android - 相对布局中的ImageView和listview

转载 作者:行者123 更新时间:2023-11-30 03:47:39 26 4
gpt4 key购买 nike

我试图将 imageview 和 listview 放在两个独立的相对布局中,但是当我将图像添加到 imageview 时,图像的高度低于应有的高度,它在图像和 listview 之间添加了一些黑色空间。但是当我放置 textview 时它工作正常。这是代码 fragment ..

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight">
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginTop="-10dp"
android:src="@drawable/bar" />

</RelativeLayout>

<ListView
android:id="@+id/list11"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="65dp"
android:cacheColorHint="#000000"
android:focusable="false"
android:listSelector="@color/itemcolor1"
android:scrollbars="vertical"
android:scrollingCache="false" >
</ListView>

</RelativeLayout>

谢谢大家,这很烦人

最佳答案

感谢大家的回答,帮助解决了很多问题,但这些答案需要稍作调整,所以我写在这里供其他人将来引用

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="65dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:scaleType="fitXY"
android:layout_weight="2"
android:layout_marginTop="-10dp"
android:src="@drawable/bar" />

<ListView
android:id="@+id/list11"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_below="@+id/imageView1"
android:cacheColorHint="#000000"
android:focusable="false"
android:layout_weight="8"
android:scrollbars="vertical"
android:scrollingCache="false"
android:listSelector="@color/itemcolor1">
</ListView>

</RelativeLayout>

关于android - 相对布局中的ImageView和listview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14706635/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com