ScrollView底部的按钮被切断

时间:2019-06-03 20:42:40

标签: android android-layout

我有一个scrollview,它与whatsapp组信息部分非常相似。它显示了所有组参与者的列表(recyclerview)和一个退出组的按钮。问题是,当recyclerview中有5个或6个以上的人时,请假组按钮(ID-groupInfoLeaveGroupButton)从显示屏底部移出,我无法向下滚动到它。

我不知道为什么会这样,感谢您的帮助。

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>

2 个答案:

答案 0 :(得分:2)

您的recyclerview占据了所有空间,需要对其进行设置,使其显示在按钮上方。像这样改变它

<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">

答案 1 :(得分:0)

可能是因为您在回收商视图中有余地。您可以删除它或在滚动视图子视图底部添加不可见视图

        <View
        android:layout_width="match_parent"
        android:layout_height="20dp"/>

       </LinearLayout>

    </ScrollView>

</LinearLayout>
相关问题