【发布时间】:2018-11-01 05:47:07
【问题描述】:
在我的页面中,我在下面的顶部有一个 searchView,它有一个 viewPager 来显示图像和一个 expandablelistview。当列表视图展开时,我需要将整个视图向上滚动到顶部,我该如何实现这一点,请帮助
<?xml version="1.0" encoding="utf-8"?>
<Scrollview
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="?actionBarSize">
<SearchView
android:id="@+id/search_bar"
android:layout_width="401dp"
android:layout_height="45dp"
android:layout_alignParentTop="true"
android:background="@drawable/bg_white_rounded"
android:queryBackground="@android:color/transparent"
android:queryHint="Search" />
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_below="@+id/Constraint1"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ExpandableListView
android:id="@+id/expandible_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@null"
android:groupIndicator="@null"
android:isScrollContainer="false"
android:layout_below="@id/Constraint2"
android:childDivider="#00000000"
/>
</RelativeLayout>
</Scrollview>
【问题讨论】:
-
要么删除父
ScrollView,要么将其替换为NestedScrollView并禁用ListView上的嵌套滚动。 -
对不起,它不适合我
-
将
NestedScrollView与android:fillViewPort="true"一起使用,并将相对布局高度从match_parent更改为wrap_content。
标签: android expandablelistview android-scrollview android-relativelayout