简体   繁体   中英

How can I make my RecyclerView behind a FloatingActionsMenu fully scrollable?

I have written this app that shows Bus routes at my university. The App itself is working fine but there is a problem with the Layout: Not all of my RecyclerView is scrollable, as you can see in this picture. The green square is scrollable, but the red one does not scroll, even if the FloatingActionsMenu is no expanded.

The FloatingActionsMenu is made with this library.

The XML-Code for the RecyclerView and the FloatingActionsMenu is:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:background="@drawable/aachen_background">

....

<android.support.v7.widget.RecyclerView
        android:duplicateParentState="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/multi_cards"
        android:layout_below="@id/maincard" />


       <com.getbase.floatingactionbutton.FloatingActionsMenu
           android:id="@+id/action_button"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:clickable="true"
           fab:fab_addButtonColorNormal="@color/fab_color"
           app:fab_addButtonColorPressed="@color/fab_color"
           fab:fab_addButtonPlusIconColor="@color/black_semi_transparent"
           fab:fab_addButtonSize="normal"
           fab:fab_labelsPosition="left"
           fab:fab_labelStyle="@style/menu_labels_style"
           app:fab_addButtonStrokeVisible="false"
           android:layout_alignParentBottom="true"
           android:layout_alignParentEnd="true"
           android:layout_below="@+id/maincard">
           <com.getbase.floatingactionbutton.FloatingActionButton
               android:id="@+id/find_activity"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               fab:fab_colorNormal="@color/fab_color"
               fab:fab_colorPressed="@color/fab_color"
               fab:fab_title="@string/find_activity"
               fab:fab_icon="@mipmap/find_activity"
               fab:fab_size="mini" />

           <com.getbase.floatingactionbutton.FloatingActionButton

               android:id="@+id/appointment_finder"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               fab:fab_colorNormal="@color/fab_color"
               fab:fab_colorPressed="@color/fab_color"
               fab:fab_title="@string/appointment_finder"
               fab:fab_icon="@mipmap/appointment_finder"
               fab:fab_size="mini"/>

           <com.getbase.floatingactionbutton.FloatingActionButton

               android:id="@+id/new_ralph"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               fab:fab_colorNormal="@color/fab_color"
               fab:fab_colorPressed="@color/fab_color"
               fab:fab_title="@string/new_ralph"
               fab:fab_icon="@mipmap/new_ralph"
               fab:fab_size="mini"/>




       </com.getbase.floatingactionbutton.FloatingActionsMenu>

</RelativeLayout>

I have already tried:

  • setting the android:visibility attribute to GONE or VISIBLE base on the isExpanded()-State of the FloatingActionsMenu
  • setting android:duplicateParentState="true"

The Full XML-Code of this Screen is:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:background="@drawable/aachen_background">


    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="16dp"
        android:id="@+id/maincard"
        app:cardBackgroundColor="@color/transparent"
        app:cardCornerRadius="@dimen/maincard_corner_radius">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:layout_margin="20dp">
            <!-- Left Part: Time and beneath Calendar RalphEvent -->
            <LinearLayout
                android:layout_width="174dp"
                android:layout_height="wrap_content"
                android:orientation="vertical">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/maincard_get_up_time"
                    android:gravity="start"
                    android:textSize="60sp"
                    android:text="@string/maincard_get_up_time"
                    android:textColor="@color/maincard_text_color"
                    />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/maincard_event_start"
                    android:textSize="20sp"
                    android:text="@string/maincard_event_start"
                    android:textColor="@color/maincard_text_color"
                    android:paddingTop="15dp" />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/maincard_event_title"
                    android:textSize="35sp"
                    android:text="@string/maincard_event_title"
                    android:textColor="@color/maincard_text_color"
                    android:ellipsize="end"
                    android:singleLine="true"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/maincard_event_location"
                    android:text="@string/maincard_event_location"
                    android:textSize="20sp"
                    android:textColor="@color/maincard_text_color"
                    android:paddingBottom="15dp"
                    android:ellipsize="end"
                    android:singleLine="true"/>
            </LinearLayout>
            <!-- Right Part: Weather and Transportation Info -->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:gravity="right">
                    <ImageView
                        android:layout_width="40dp"
                        android:layout_height="40dp"
                        android:paddingRight="5dp"
                        android:contentDescription="@string/weather_icon"
                        android:id="@+id/maincard_weather_icon"
                        android:src="@drawable/weather_icon_rain" />
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:id="@+id/maincard_weather"
                        android:text="@string/maincard_weather"
                        android:layout_gravity="center_vertical"
                        android:textSize="30sp"
                        android:textColor="@color/maincard_secondary_color" />


                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:paddingTop="10dp"
                    android:gravity="right">
                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="40dp"
                        android:paddingRight="5dp"
                        android:contentDescription="@string/bus_icon"
                        android:id="@+id/maincard_transport_icon"
                        android:src="@drawable/transport_icon_bus" />
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_vertical"
                        android:id="@+id/maincard_departure_time"
                        android:text="@string/maincard_departure_time"
                        android:textSize="30sp"
                        android:textColor="@color/maincard_secondary_color" />
                </LinearLayout>
            </LinearLayout>


        </LinearLayout>
    </android.support.v7.widget.CardView>
    <android.support.v7.widget.RecyclerView
        android:duplicateParentState="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/multi_cards"
        android:layout_below="@id/maincard" />


       <com.getbase.floatingactionbutton.FloatingActionsMenu
           android:id="@+id/action_button"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:clickable="true"
           fab:fab_addButtonColorNormal="@color/fab_color"
           app:fab_addButtonColorPressed="@color/fab_color"
           fab:fab_addButtonPlusIconColor="@color/black_semi_transparent"
           fab:fab_addButtonSize="normal"
           fab:fab_labelsPosition="left"
           fab:fab_labelStyle="@style/menu_labels_style"
           app:fab_addButtonStrokeVisible="false"
           android:layout_alignParentBottom="true"
           android:layout_alignParentEnd="true"
           android:layout_below="@+id/maincard">
           <com.getbase.floatingactionbutton.FloatingActionButton
               android:id="@+id/find_activity"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               fab:fab_colorNormal="@color/fab_color"
               fab:fab_colorPressed="@color/fab_color"
               fab:fab_title="@string/find_activity"
               fab:fab_icon="@mipmap/find_activity"
               fab:fab_size="mini" />

           <com.getbase.floatingactionbutton.FloatingActionButton

               android:id="@+id/appointment_finder"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               fab:fab_colorNormal="@color/fab_color"
               fab:fab_colorPressed="@color/fab_color"
               fab:fab_title="@string/appointment_finder"
               fab:fab_icon="@mipmap/appointment_finder"
               fab:fab_size="mini"/>

           <com.getbase.floatingactionbutton.FloatingActionButton

               android:id="@+id/new_ralph"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               fab:fab_colorNormal="@color/fab_color"
               fab:fab_colorPressed="@color/fab_color"
               fab:fab_title="@string/new_ralph"
               fab:fab_icon="@mipmap/new_ralph"
               fab:fab_size="mini"/>




       </com.getbase.floatingactionbutton.FloatingActionsMenu>

</RelativeLayout>
<android.support.design.widget.NavigationView
    android:id="@+id/navigation_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="@android:color/white"
    app:headerLayout="@layout/navigation_drawer"
/>

如何从FloatingActionsMenu中删除此行呢?

android:clickable="true"

Try set main layout as frame. Try this:

<FrameLayout>

    <LinearLayout>

        <CardView />

        <RecyclerView />

    </LinearLayout>

    <FloatingActionsMenu />

</FrameLayout>

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM