【发布时间】:2018-07-12 07:54:38
【问题描述】:
所以,我在布局文件中得到了一个带有列表视图的片段。此列表视图上方是带有徽标的图像视图。
我面临的问题是我无法将滚动设置为整个布局。 我在其他帖子上有红色,你不应该这样做,但如果我必须以另一种方式来做,我必须重做很多代码。
我还从 API 获取数据,并且元素的数量可能会发生变化。这就是我使用列表视图的原因。
我没有关于布局类型的偏好。目前我正在使用 ScrollView 布局。
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.HomeFragment"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:src="@drawable/logo"/>
<ListView
android:id="@+id/listFemArrangementer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:listSelector="@color/white"
android:scrollbars="none">
</ListView>
</LinearLayout>
谁有解决这个问题的好办法?
【问题讨论】:
-
请将您的代码添加为文本而不是图像
-
使用 android.support.v4.widget.NestedScrollView 而不是 ScrollView
-
@Subzero 将滚动视图更改为嵌套滚动视图,但没有任何变化。列表自行滚动,但图像不随列表滚动。我想要一种同时滚动图像和列表视图的静态布局
-
如果你不需要滚动,为什么不使用 LinearLayout 而不是 ListView?
-
因为元素的数量没有确定,可能是2个,也可能是5个。我不知道有什么更好的方法来做到这一点。 @Subzero
标签: android listview android-fragments imageview