我有一个Fragment
我在ViewPager
中显示View
,其中包含有关用户的一些信息,RecyclerView
下方有Fragment
。问题是,每当我滚动到RecyclerView
时,页面会自动向下滚动到Fragment
开始的位置,我不希望这种情况发生。相反,我希望你在浏览<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:theme="@style/AppTheme.AppBarOverlay"
app:layout_scrollFlags="scroll|enterAlways" />
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:tabTextColor="@android:color/white"
app:tabSelectedTextColor="@android:color/white"
app:tabIndicatorColor="@android:color/white"
app:tabIndicatorHeight="3dp"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_create_white_24dp"
app:borderWidth="0dp"
app:layout_behavior="com.tabs.activity.ScrollingFabBehavior"/>
</android.support.design.widget.CoordinatorLayout>
时滚动到你最后离开的地方。这是我的尝试:
activity_main.xml中:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_horizontal"
android:id="@+id/profile_header">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="24sp"
android:textColor="@color/black"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
android:id="@+id/profile_name"/>
<com.facebook.drawee.view.SimpleDraweeView
android:layout_marginTop="16dp"
android:id="@+id/profile_picture"
android:layout_width="100dp"
android:layout_height="100dp"
fresco:roundingBorderColor="@color/white"
fresco:roundingBorderWidth="10dp"
fresco:placeholderImageScaleType="centerCrop"
fresco:placeholderImage="@mipmap/blank_prof_pic"
fresco:roundAsCircle="true"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/button_row"
android:orientation="horizontal"
android:layout_width="match_parent"
android:weightSum="4"
android:layout_below="@id/profile_header"
android:layout_marginTop="12dp"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
...Content here...
</RelativeLayout>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rv_posts_feed"
android:visibility="gone"
/>
是profile.xml:
{{1}}