I've been searching everywhere for this issue. I have aligned a LinearLayout to the bottom of the parent relative layout and also a RecyclerView, as same level child, the thing is that list does not detect the element on bottom and it scrolls till the end, so I can't see the last row of the list. This is my code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_marginTop="10dp"
android:clipToPadding="false"
android:clipChildren="false"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--some code-->
<LinearLayout
android:layout_below="@+id/comments"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewComments"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:shadowColor="#000"
android:shadowDx="-2"
android:shadowRadius="8"
android:shadowDy="-10"
android:layout_marginTop="10dp"
android:layout_height="wrap_content">
<!--some code-->
</LinearLayout>
</RelativeLayout>
Try below code.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_marginTop="10dp"
android:clipToPadding="false"
android:clipChildren="false"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--some code-->
<LinearLayout
android:id="@+id/recyclerViewContainer"
android:layout_below="@+id/comments"
android:layout_above="@+id/bottomLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewComments"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent" />
</LinearLayout>
<LinearLayout
android:id="@+id/bottomLinearLayout"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:shadowColor="#000"
android:shadowDx="-2"
android:shadowRadius="8"
android:shadowDy="-10"
android:layout_marginTop="10dp"
android:layout_height="wrap_content">
<!--some code-->
</LinearLayout>
</RelativeLayout>
Basically, your bottom LinearLayout overlaps the RecyclerView. By using android:layout_above
on the parent layout of RecyclerView we can avoid that.
set android:layout_above
property to set the container of recyclerView avobe the footer
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_marginTop="10dp"
android:clipToPadding="false"
android:clipChildren="false"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--some code-->
<LinearLayout
android:layout_below="@+id/comments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/aLayout">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewComments"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent" />
</LinearLayout>
<LinearLayout
android:id="@+id/aLayout"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:shadowColor="#000"
android:shadowDx="-2"
android:shadowRadius="8"
android:shadowDy="-10"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<!--some code-->
</LinearLayout>
</RelativeLayout>
You are not posting the complete code. But in your case you just create an LinearLayout and set android:layout_alignParentBottom="true"
. This is ok..
But in your Linearlayout which contains the Recycler you are adding this android:layout_below="@+id/comments"
. Only that is not enough. You need to add the layout above attribute
android:layout_above="@+id/bottomLayout"
尝试在LinearLayout上添加一个paddingBottom,该底部包含与Recycler中的适配器具有相同高度的Recycler
将LinearLayout更改为RelativeLayout,其位于回收站下方
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.