[英]How to place textView on top of the recycler view?
I have a recyclerView (Shimmer RecyclerView) and a fab. 我有一个recyclerView(Shimmer RecyclerView)和一个晶圆厂。 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.
我需要显示我的晶圆厂的描述,但是当我在xml文件中放置textView时,textView显示在recyclerView的后面,而我需要在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
). CoordinatorLayout
从FrameLayout
扩展而来,因此每个子View
都堆叠在前一个View
的顶部( FloatingActionButton
是一个例外,因为此View
专门由CoordinatorLayout
管理)。
So you need to swap the TextView
and the RecyclerView
to achieve the desired effect (at least it works with a "normal" RecyclerView
) 因此,您需要交换
TextView
和RecyclerView
以获得所需的效果(至少它可以与“正常”的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中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.