[英]Button at bottom of ScrollView getting cut off
I have a scrollview
which is very similar to the whatsapp group info section. 我有一个
scrollview
,它与whatsapp组信息部分非常相似。 It shows a list ( recyclerview
) of all the group participants, and a button to leave the group. 它显示了所有组参与者的列表(
recyclerview
),以及退出该组的按钮。 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. 问题是,当
recyclerview
中的人数超过5或6个时,请假组按钮(ID- groupInfoLeaveGroupButton
)从显示的底部移除,而我无法向下滚动。
I've got no idea why this is happening, any help is appreciated. 我不知道为什么会这样,感谢您的帮助。
The recyclerview has setNestedScrollingEnabled(false) set. recyclerview已设置setNestedScrollingEnabled(false)。
<?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>
Your recyclerview
is occupying all the space, it needs to be set so that it displays above the button. 您的
recyclerview
占据了所有空间,需要对其进行设置,使其显示在按钮上方。 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">
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.