我写过这个应用程序,显示我大学的巴士路线。应用程序本身工作正常,但布局有问题: 并非我的所有RecyclerView都可滚动,您可以在this图片中看到。 绿色方块是可滚动的,但红色方块不滚动,即使FloatingActionsMenu未展开。
FloatingActionsMenu由this库创建。
RecyclerView和FloatingActionsMenu的XML代码是:
<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>
我已经尝试过了:
此屏幕的完整XML代码是:
<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"
/>
答案 0 :(得分:0)
如何从FloatingActionsMenu中删除此行?:
android:clickable="true"
答案 1 :(得分:0)
尝试将主布局设置为框架。 试试这个:
<FrameLayout>
<LinearLayout>
<CardView />
<RecyclerView />
</LinearLayout>
<FloatingActionsMenu />
</FrameLayout>