I have a recyclerView (Shimmer RecyclerView) and a fab. I need to display a description for my fab but when I place a textView in the xml file, the textView is displayed behind the recyclerView while I need it on top of the recyclerView. Any idea how to achieve the disired result?
My code:
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.FloatingActionButton
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="bottom|left"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|left"
android:layout_marginLeft="80dp"
android:layout_marginBottom="21dp"
android:background="@drawable/dark_gray_rounded"
android:gravity="center"
android:padding="10dp"
android:text="someText"
android:textColor="@color/white" />
<com.cooltechworks.views.shimmer.ShimmerRecyclerView xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingTop="15dp"
app:shimmer_demo_angle="35"
app:shimmer_demo_child_count="10"
app:shimmer_demo_layout_manager_type="linear_vertical"
app:shimmer_demo_reverse_animation="true" />
</android.support.design.widget.CoordinatorLayout>
Try this:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.FloatingActionButton
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="bottom|left"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp" />
<com.cooltechworks.views.shimmer.ShimmerRecyclerView xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingTop="15dp"
app:shimmer_demo_angle="35"
app:shimmer_demo_child_count="10"
app:shimmer_demo_layout_manager_type="linear_vertical"
app:shimmer_demo_reverse_animation="true"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|left"
android:layout_marginLeft="80dp"
android:layout_marginBottom="21dp"
android:background="@drawable/dark_gray_rounded"
android:gravity="center"
android:padding="10dp"
android:text="someText"
android:textColor="@color/white" />
I have tried this. It works same as you wish in question. I Hope this work for you.
CoordinatorLayout
extends from FrameLayout
, so the child View
s are stacked each on top of the previous one (with the FloatingActionButton
as an exception because this View
specifically is managed by the CoordinatorLayout
).
So you need to swap the TextView
and the RecyclerView
to achieve the desired effect (at least it works with a "normal" RecyclerView
)
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.FloatingActionButton
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="bottom|left"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp" />
<com.cooltechworks.views.shimmer.ShimmerRecyclerView xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingTop="15dp"
app:shimmer_demo_angle="35"
app:shimmer_demo_child_count="10"
app:shimmer_demo_layout_manager_type="linear_vertical"
app:shimmer_demo_reverse_animation="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|left"
android:layout_marginLeft="80dp"
android:layout_marginBottom="21dp"
android:background="@drawable/dark_gray_rounded"
android:gravity="center"
android:padding="10dp"
android:text="someText"
android:textColor="@color/white" />
</android.support.design.widget.CoordinatorLayout>
将fab和textView组织在一个单独的布局中,并将其包括在您的coordinatorLayout中
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.