Reputation: 454
I have a scrollview
which is very similar to the whatsapp group info section. It shows a list (recyclerview
) of all the group participants, and a button to leave the group. The problem is, when there is more than 5 or 6 people in the recyclerview
, the leave group button (ID - groupInfoLeaveGroupButton
) gets removed from the bottom of the display and I can't scroll down to it.
I've got no idea why this is happening, any help is appreciated.
The recyclerview has setNestedScrollingEnabled(false) set.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="whatsappmock.com.activities.GroupInformation">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ToolbarTheme">
<androidx.appcompat.widget.Toolbar
android:id="@+id/groupInfoToolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/whiteText"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</com.google.android.material.appbar.AppBarLayout>
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="225dp">
<ImageView
android:id="@+id/groupInfoGroupImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/no_group_icon" />
<Button
android:id="@+id/groupInfoChangeImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="10dp"
android:alpha="0.3"
android:background="#000000"
android:fontFamily="@font/cairo"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text="Change Group Image"
android:textColor="@color/whiteText"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout
android:id="@+id/groupInfoGroupDescriptionContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="@color/whiteText"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="3dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:text="@string/groupInfoGroupDescription"
android:textColor="@color/colorAccent"
android:textSize="18sp" />
<TextView
android:id="@+id/groupDescriptionTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textSize="15sp"
tools:text="Test Description" />
</LinearLayout>
<TextView
android:id="@+id/groupInfoNumberOfParticipants"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="@color/whiteText"
android:paddingLeft="10dp"
android:paddingTop="3dp"
android:paddingRight="10dp"
android:paddingBottom="3dp"
android:textSize="16sp"
tools:text="8 Participants" />
<View
android:layout_width="match_parent"
android:layout_height="1dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/groupInfoParticipantsRv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:background="@color/whiteText">
</androidx.recyclerview.widget.RecyclerView>
<Button
android:id="@+id/groupInfoLeaveGroupButton"
android:layout_width="match_parent"
android:layout_height="55dp"
android:background="@drawable/leave_group_rounded_button_bg"
android:fontFamily="@font/cairo"
android:gravity="center"
android:text="@string/group_info_leave_group"
android:textColor="@color/whiteText"
android:textSize="25sp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
Upvotes: 0
Views: 590
Reputation: 29260
Your recyclerview
is occupying all the space, it needs to be set so that it displays above the button. Change it like this
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/groupInfoParticipantsRv"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginBottom="20dp"
android:background="@color/whiteText">
Upvotes: 3
Reputation: 689
Probably it's because of your margin in recycler view. You can remove it or add invisible view at the bottom of scroll view child
<View
android:layout_width="match_parent"
android:layout_height="20dp"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
Upvotes: 0