【发布时间】:2018-04-27 03:40:40
【问题描述】:
这是我的 XML 布局,我想在其中显示/隐藏相对布局 (@+id/room_header_rl) 而不是 actiob_bar。请有人知道该怎么做吗? 我尝试使用 CoordinatorLayout 但没有成功。 提前谢谢你。
我的 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/,但它只显示/隐藏 actionBar。
【问题讨论】:
标签: android scroll android-recyclerview hide android-relativelayout