2016-12-04 11 views
0

私はアンドロイドの初心者です。なぜこれが起こるのかわかりません。 SwipeRefreshLayoutがないと、RecyclerViewは完全に表示されますが、SwipeRefreshLayoutでは最初の項目は表示されません。SwipeRefreshLayoutはRecyclerViewの上部を隠しますか?

おそらく、ツールバーの下にありますか? (隠されたアイテムは、私はさまざまな方法でそれを確認し、存在しています。)

<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:id="@+id/swipe_layout"> 

<android.support.v7.widget.RecyclerView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/MainRecyclerView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 
</android.support.v7.widget.RecyclerView> 

</android.support.v4.widget.SwipeRefreshLayout> 

一覧:

<?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:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:paddingTop="8dip" 
    android:paddingBottom="8dip" 
    android:paddingLeft="16dip" 
    android:paddingRight="16dip" 
    android:weightSum="10" 
    android:gravity="center"> 


    <ImageView 
     android:id="@+id/CharacterItemRankImageView" 
     android:layout_width="50dp" 
     android:layout_height="50dp" 
     android:layout_weight="0" 
     android:src="@drawable/challengemode_medal_bronze"/> 

    <TextView android:id="@+id/CharacterItemNameTextView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="3.5" 
     tools:text="Name"/> 


    <TextView android:id="@+id/CharacterItemPointsTextView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAlignment="center" 
     android:layout_weight="6" 
     tools:text="Points"/> 

    <ImageButton 
     android:id="@+id/CharacterItemRemoveButton" 
     android:layout_width="50dp" 
     android:layout_height="50dp" 
     android:layout_weight="0.5" 
     android:src="@drawable/ic_delete_grey600_48dp" 
     android:scaleType="fitXY" style="@style/Widget.AppCompat.Button.Borderless" /> 

</LinearLayout> 

Without Swipe

With Swipe

答えて

1

私はあなたがのルートとしてCoordinatorLayoutを使用していると思いますあなたの意見その場合、起こっているのは、ツールバーがRecyclerViewの最初のアイテムによって隠されているということです。

この問題を解決するには、レイアウトの動作をSwipeRefreshLayoutに追加し、RecyclerViewから削除するだけです。

<android.support.v4.widget.SwipeRefreshLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/swipe_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

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

</android.support.v4.widget.SwipeRefreshLayout> 
関連する問題