Android 如何将textView放在回收器视图的顶部?
我有一个recyclerView闪片recyclerView和一个晶圆厂。我需要显示我的工厂的描述,但是当我在xml文件中放置textView时,textView显示在recyclerView后面,而我需要它显示在recyclerView上面。你知道如何达到预期的效果吗 我的代码:Android 如何将textView放在回收器视图的顶部?,android,Android,我有一个recyclerView闪片recyclerView和一个晶圆厂。我需要显示我的工厂的描述,但是当我在xml文件中放置textView时,textView显示在recyclerView后面,而我需要它显示在recyclerView上面。你知道如何达到预期的效果吗 我的代码: <android.support.design.widget.CoordinatorLayout android:layout_width="match_parent" andr
<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>
在单独的布局中组织fab和textView,并将其包括在coordinatorLayout中coordinatorLayout扩展自FrameLayout,因此子视图以FloatingActionButton作为例外堆叠在前一个视图的顶部,因为此视图专门由coordinatorLayout管理 因此,您需要交换TextView和RecyclerView以实现所需的效果,至少它可以与普通的RecyclerView一起工作 试试这个:
<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" />
我试过这个。它的工作原理与您所希望的相同。我希望这对你有用。很高兴你把它修好了!
<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" />