如何阻止ScrollView自动移动

时间:2016-03-13 07:06:15

标签: android layout android-scrollview

layout.xml 下面

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView
    android:focusableInTouchMode="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/category_layout_top"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:descendantFocusability="beforeDescendants"
    >
<ImageView
    android:fitsSystemWindows="true"
    android:layout_width="390dp"
    android:layout_height="390dp"
    android:scaleType="centerCrop"
    android:id="@+id/category_Image_View"/>

</FrameLayout>
<LinearLayout

android:layout_width="match_parent"
android:layout_height="50dp"
android:id="@+id/category_linearlayout">
<TextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:singleLine="true"
 android:id="@+id/category_textView"
    />
</LinearLayout>

<android.support.v7.widget.RecyclerView
    android:id="@+id/category_recycler_view"

    android:layout_width="match_parent"
    android:padding="10dp"

    android:scrollbars="vertical"
    android:layout_height="wrap_content"
    android:clickable="true"/>

</LinearLayout>

</ScrollView>

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/def_toolbar"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:minHeight="?attr/actionBarSize"
    android:background="#00FFFFFF"
    android:layout_alignParentTop="true" />
</FrameLayout>

每当相应的活动开始时,ScrollView最终会自动显示RecyclerView的最后一项。如何防止这种情况?

我试图删除android:descendantFocuabiity =&#34; beforeDescendants&#34;来自包含ImageView的Framelayout以防万一,看看它是否有效,而且它没有。

提前致谢!

0 个答案:

没有答案
相关问题