1

アクションモードの開始時にRecyclerviewのビューをCoordinatorlayoutに表示しようとしています。しかし、私が下にスクロールするまでは見えません。 app:layout_behavior="@string/appbar_scrolling_view_behavior"を削除した場合は、 を取得しますが、Recyclerviewはツールバーの下に表示されます。 Coordinatorlayoutを使用して、どのように視界を常に見えるようにするかに関する提案。コーディネーターレイアウトの下部ビューがスクロールダウンされるまで表示されない

主レイアウト:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:fab="http://schemas.android.com/apk/res-auto" 
android:id="@+id/main_content" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="false"> 


<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <include layout="@layout/toolbar" /> 
</android.support.design.widget.AppBarLayout> 


    <include layout="@layout/list" /> 
</android.support.design.widget.CoordinatorLayout> 

リストのレイアウト:変更以下

<RelativeLayout 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" 
android:orientation="vertical" 
app:layout_behavior="@string/appbar_scrolling_view_behavior"> 


<LinearLayout        
    android:id="@+id/bottomView" 
    android:layout_width="match_parent" 
    android:layout_height="200dp" 
    android:layout_alignParentBottom="true" 
    android:background="@color/colorPrimary" 
    android:orientation="vertical"> 

</LinearLayout> 

<android.support.v4.widget.SwipeRefreshLayout 
    android:id="@+id/swipeRefreshLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@+id/layoutDummy"> 


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

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

</RelativeLayout> 

答えて

0

試み、それが目に見える境界の外に、あなたの下のビューを押さずにビューの高さを計算する必要があります「layout_weight」プロパティを使用します。 (実行時の許容可能な高さを計算します)。

は、私がコーディネーターレイアウトに子として直接底面図を追加することで解決策を持っている

<LinearLayout 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" 
 
android:orientation="vertical" 
 
app:layout_behavior="@string/appbar_scrolling_view_behavior"> 
 

 

 

 

 
<android.support.v4.widget.SwipeRefreshLayout 
 
    android:id="@+id/swipeRefreshLayout" 
 
    android:layout_width="match_parent" 
 
    android:layout_height="0dp" 
 
    android:layout_weight="1"           
 
    android:layout_above="@+id/layoutDummy"> 
 

 

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

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

 
    <LinearLayout        
 
    android:id="@+id/bottomView" 
 
    android:layout_width="match_parent" 
 
    android:layout_height="200dp" 
 
    android:background="@color/colorPrimary" 
 
    android:orientation="vertical"> 
 

 
</LinearLayout> 
 
    
 
</LinearLayout>

+0

それは動作しません。スクロールすると、ボトムビューのみが表示されます。コーディネーターのレイアウトのスクロール動作が原因です。 – RisingUp

0

(私はあなたがリサイクラービューの下に表示するビューlinerlayoutがあると仮定しました)起動アクションモードで表示させることができます。しかし、この解決法の短所は、Recyclerviewの最後の行を隠すことです。そこで、Recyclerviewの最後に空のフッターを追加する必要がありました。より良いソリューションが大歓迎です。

主レイアウト:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     xmlns:fab="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/main_content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="false"> 


    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <include layout="@layout/toolbar" /> 
    </android.support.design.widget.AppBarLayout> 


     <include layout="@layout/list" /> 

<!-- BOTTOM VIEW --> 
    <LinearLayout        
     android:id="@+id/bottomView" 
     android:layout_width="match_parent" 
     android:layout_height="200dp" 
     android:layout_alignParentBottom="true" 
     android:background="@color/colorPrimary" 
     android:orientation="vertical"/> 
    </android.support.design.widget.CoordinatorLayout> 

リストのレイアウト:

<LinearLayout 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" 
     android:orientation="vertical" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 


    <android.support.v4.widget.SwipeRefreshLayout 
     android:id="@+id/swipeRefreshLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@+id/layoutDummy"> 


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

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

    </LinearLayout> 

は、アダプタ:

private static final int TYPE_ITEM = 1; 
private static final int TYPE_FOOTER = 2; 

@Override 
public int getItemViewType(int position) { 
    if (isPositionFooter(position)) { 
     return TYPE_FOOTER; 
    } 
    return TYPE_ITEM; 
} 

private boolean isPositionFooter(int position) { 
    return position == list.size(); 
} 


@Override 
public int getItemCount() { 
    if (list == null) { 
     return 0; 
    } else { 
     return list.size() + 1; 
    } 
} 
関連する問題