1

이것은 actiob_bar가 아닌 상대 레이아웃 (@ + id/room_header_rl)을 표시하거나 숨기고 싶은 XML 레이아웃입니다. 어떻게 만드는지 생각 해보세요. CoordinatorLayout을 사용해 보았지만 성공하지 못했습니다. 미리 감사드립니다.Recycleview 목록이 스크롤 될 때 상대 레이아웃을 숨기거나 표시 할 수 있습니까?

내 XML 레이아웃 :

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/white"> 

    <include 
     android:id="@+id/app_bar" 
     layout="@layout/app_bar"/> 

    <RelativeLayout 
     android:id="@+id/room_header_rl" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/white" 
     android:padding="10dp" 
     android:layout_below="@+id/app_bar" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true"> 

     <RelativeLayout 
      android:id="@+id/room_details_rl" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <ImageView 
       android:id="@+id/room_img" 
       android:layout_width="80dp" 
       android:layout_height="80dp" 
       android:layout_marginRight="10dp" 
       android:scaleType="centerCrop" 
       android:layout_centerVertical="true"/> 

      <RelativeLayout 
       android:id="@+id/rooom_rl" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_toRightOf="@+id/room_img" 
       android:layout_centerVertical="true"> 

       <TextView 
        android:id="@+id/roomname_tv" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textColor="@color/black" 
        android:textSize="15sp" 
        android:textStyle="bold" 
        android:maxLines="2" 
        android:drawablePadding="5dp"/> 

       <TextView 
        android:id="@+id/roomdate_tv" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textColor="@color/black" 
        android:layout_below="@+id/roomname_tv" 
        android:layout_marginTop="10dp"/> 

       <EditText 
        android:id="@+id/roommembers_tv" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textColor="@color/black" 
        android:textSize="14sp" 
        android:layout_below="@+id/roomdate_tv" 
        android:focusable="false"/> 

      </RelativeLayout> 

     </RelativeLayout> 

     <TextView 
      android:id="@+id/welcome_msg_txt" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:maxLines="4" 
      android:padding="5dp" 
      android:gravity="center" 
      android:textStyle="bold" 
      android:background="@color/light_gray" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:layout_marginTop="10dp" 
      android:layout_below="@+id/room_details_rl" 
      android:layout_centerHorizontal="true" /> 

     <View 
      android:layout_width="match_parent" 
      android:layout_height="1dp" 
      android:layout_marginTop="5dp" 
      android:background="@color/gray" 
      android:layout_below="@+id/welcome_msg_txt"/> 

    </RelativeLayout> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/roomchat_rv" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginBottom="5dp" 
     android:layout_marginTop="20dp" 
     android:layout_above="@+id/divider" 
     android:layout_below="@+id/room_header_rl"/> 

    <View 
     android:id="@+id/divider" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:background="@color/gray" 
     android:layout_above="@+id/entertext_rl"/> 

<RelativeLayout 
    android:id="@+id/entertext_rl" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true"> 

    <EditText 
     android:id="@+id/entertext_ed" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:textColor="@color/black" 
     android:layout_marginTop="5dp" 
     android:layout_marginBottom="5dp" 
     android:layout_marginLeft="5dp" 
     android:maxLines="3" 
     android:textSize="16sp" 
     android:capitalize="sentences" 
     android:hint="@string/entertext" 
     android:layout_toLeftOf="@id/attech_btn" 
     android:background="@android:color/transparent" 
     android:layout_centerVertical="true"/> 

    <Button 
     android:id="@+id/attech_btn" 
     android:layout_width="30dp" 
     android:layout_height="30dp" 
     android:layout_centerVertical="true" 
     android:layout_marginRight="10dp" 
     android:layout_toLeftOf="@+id/send_btn" 
     android:background="@drawable/attach"/> 

    <Button 
     android:id="@+id/send_btn" 
     android:layout_width="30dp" 
     android:layout_height="30dp" 
     android:layout_centerVertical="true" 
     android:layout_alignParentRight="true" 
     android:layout_marginRight="10dp" 
     android:background="@drawable/send_btn"/> 

</RelativeLayout> 

내가 https://mzgreen.github.io/2015/06/23/How-to-hideshow-Toolbar-when-list-is-scrolling%28part3%29/을 시도하고 있지만 /는 액션 바을 숨길 쇼입니다.

답변

1

프로그래밍 방식으로 숨기려고 했습니까?

recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { 
     @Override 
     public void onScrolled(RecyclerView recyclerView, int dx, int dy) { 
      super.onScrolled(recyclerView, dx, dy); 
      my_relative_layout.setVisibility(View.GONE); 
     } 
    }); 
+0

레이아웃을 숨기기 만하면 레이아웃이 위아래로 움직이는 것처럼 보이지 않습니다. 이것은 내 질문에 대한 적절한 해결책이 아닙니다. –

+0

아, 툴바와 동일한 동작을 원하십니까? – Boukharist

+0

예 도구 모음 애니메이션과 동일 –