在我的页面中,我的顶部下方有一个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>
答案 0 :(得分:0)
u可以在您的代码中使用它
mainScrollView.fullScroll(ScrollView.FOCUS_UP);