2016-05-14 9 views
1

RecyclerViewとツールバーで簡単なCoordinatorLayoutを作成したいのですが、標準的な解決策との違いは、ツールバーが下部にある必要があり、RecyclerViewが下部にスクロールすると消えるはずです。CoordinatorLayoutの下部にあるツールバー

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 
    android:id="@+id/main_content" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar_bottom" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"/> 

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

</android.support.design.widget.CoordinatorLayout> 

もちろんツールバーではなく、下部の一番上にある:

は、だから私はシンプルなレイアウトを作成しました。どうすれば修正できますか?

答えて

3

うわー、それはそれがわからないクールなアイディア、ですが、あなたはこの

<android.support.design.widget.CoordinatorLayout 
    android:id="@+id/main_content" 
    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.support.v7.widget.RecyclerView 
     android:id="@+id/my_list" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
    </android.support.v7.widget.RecyclerView> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar_bottom" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom"/> 
    </android.support.design.widget.CoordinatorLayout> 

を行うことを試みることができる。しかし、正直なところ、私はそれが十分だとは思いません。

my blog articleのように通常FABで行うのと同じように、Toolbarにカスタムapp:layout_behaviorを与えることが解決策になるかもしれません。

どのようになったのか教えてください。

EDIT

私は多分あなたが探しているが、新たに導入されたbottom navigation barであることに気づきました! 私は、それを即座に実行するサードパーティ製のライブラリがたくさんあること、あるいはあなた自身の実装を試みようとしていることを知りました!

+0

で試してみてくださいは、残念ながらそれは私がClassCastExceptionが取得原因、XMLにおける第二のものはRecyclerViewする必要があり、あなたのソリューションを持つことは不可能です。 – ThirdMartian

+0

ああ、CoordinatorLayoutがFrameLayoutのサブクラスだと覚えていれば、xmlブロック内の要素を、私が推測する副作用なしに入れ替えることができます。私の編集も見てください! – fiipi

+0

ああ、私は間違っていた、それは一時的なエラーだった今、ツールバーは一番下にあり、私はスクロールでhide/showの解決策を見つけようとしている。私は下部のナビゲーションバーを使用したくないツールバー上のアイテムの原因は、コンテナ内の新しいフラグメントを置き換える代わりに新しいアクティビティを開くべきです。私は、下のナビゲーションバーのために既に作成されたlibsが私の解決には大きすぎますが、多分私はそれらを使用しなければならないことを意味します。 – ThirdMartian

0

この

<android.support.design.widget.CoordinatorLayout 
android:id="@+id/main_content" 
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.support.design.widget.AppBarLayout 
     android:id="@+id/id_appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fitsSystemWindows="true"> 

      <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar_bottom" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom" 
      app:layout_scrollFlags="scroll|enterAlways"/> 

    </android.support.design.widget.AppBarLayout> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/my_list" 
     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.design.widget.CoordinatorLayout> 
+0

私はツールバーが一番下にあることを覚えておいてください! – ThirdMartian

+0

ツールバーでこれを使用します:android:layout_gravity = "bottom" – Masum

+0

ツールバーはまだ一番上にあります – ThirdMartian

関連する問題