2

Я хочу добавить макет, который скрывает/показывает, когда прокрутка recyclerview. что макет будет скрываться, когда recyclerview прокрутит вниз, покажет, когда recyclerview прокручивается вверх, как новый твиттер. Я могу сделать это для appbarlayout, но я не могу сделать для этого макета. Как я могу это сделать?Как скрыть/показать макет, когда прокрутка recyclerview (например, макет твита twitter)

http://i.hizliresim.com/rVyDq3.png

фиолетовый макет будет скрывать шоу как ActionBar:

http://i.hizliresim.com/gAMp92.png

вот мой файл макета:

<android.support.v4.widget.DrawerLayout 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/drawerLayout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:elevation="7dp"> 

<!-- my main content --> 
<android.support.design.widget.CoordinatorLayout 
    android:id="@+id/coordinatorLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appBarLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/tool_bar" 
      style="@style/ToolBarStyle" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      android:minHeight="?attr/actionBarSize" 
      app:layout_scrollFlags="scroll|enterAlways" /> 

     <LinearLayout 
      android:orientation="vertical" 
      android:id="@+id/linearLayout" 
      android:layout_width="match_parent" 
      android:layout_height="48dp" 
      android:background="@color/color_accent_pink"> 

     </LinearLayout> 

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


    <android.support.v7.widget.RecyclerView 
     android:id="@+id/newsRecyclerView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:scrollbars="vertical" 
     android:clickable="true" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

    <!-- that layout will hide/show when recyclerview scroll --> 
    <LinearLayout 
     android:orientation="horizontal" 
     android:id="@+id/takimlar" 
     android:layout_width="match_parent" 
     android:layout_height="48dp" 
     android:background="@color/bg_group_item_swiping_active_state" 
     android:layout_gravity="bottom" > 

    </LinearLayout> 

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

<!-- my navigation drawer --> 
<RelativeLayout 
    android:id="@+id/container" 
    android:layout_width="235dp" 
    android:layout_height="match_parent" 
    android:layout_gravity="left" 
    android:background="@color/myDrawerBackground"> 


    <TextView 
     android:id="@+id/merhabaText" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="400dp" 
     android:layout_marginRight="40dp" 
     android:layout_alignParentRight="true" 
     android:text="Hello!"/> 

</RelativeLayout> 

ответ

0

У меня есть простое решение для этого ..

recyclerview.addOnScrollListener(new HidingScrollListener() 
    { 

     @Override 
     public void onHide() 
     { 

      tabss.animate().translationY(tabss.getHeight()) 
        .setInterpolator(new AccelerateInterpolator(2)).start();  
      filtershow.animate().translationY(-filtershow.getHeight()) 
        .setInterpolator(new AccelerateInterpolator(1)); 
     } 

     @Override 
     public void onShow() 
     { 
      tabss.animate().translationY(0).setInterpolator(new 
        DecelerateInterpolator(2)).start(); 
     filtershow.animate().translationY(0).setInterpolator 
       (new DecelerateInterpolator(1)).start(); 
     } 
    }); 

В этом Recyclerview я скрывала верхний экран фильтра и экран вкладки нижней Если у вас есть сомнения по поводу этого скрытого макета, спросите меня. Я предоставлю для этого необходимый вам код.