RecyclerView搶奪item焦點,導致item自動向上滑動

博客轉移到:http://www.wangchengmeng.club/

使用了RecyclerView的佈局文件代碼:

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/refreshLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@id/layoutCommentInput"
    android:descendantFocusability="afterDescendants"  //必須加上代碼
    android:layout_below="@id/feedViewerTitle">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>

item佈局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layoutHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"   //必須加上代碼
android:orientation="vertical">

<com.ums.closer.ui.feed.FeedContentView
    android:id="@+id/feedContentView"
    android:layout_width="match_parent"
    android:duplicateParentState="true"  //必須加上代碼
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/dimen_10" />

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="@dimen/dimen_10"
    android:paddingBottom="@dimen/dimen_15"
    android:paddingLeft="@dimen/phoenix_dimen_20"
    android:paddingRight="@dimen/phoenix_dimen_20"
    android:paddingTop="@dimen/dimen_15">

    <TextView
        android:id="@+id/tvFeedFrom"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:textColor="@color/color_btn_login_out"
        android:textSize="@dimen/sp_12"
        tools:text="來自成都一羣" />

    <TextView
        android:id="@+id/tvFeedTime"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right|center_vertical"
        android:textColor="@color/color_btn_login_out"
        android:textSize="@dimen/sp_12"
        tools:text="3小時前" />

</FrameLayout>
</LinearLayout>

然後就解決問題

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章