您好我是Android开发新手。Android使固定位置的浮动操作菜单
我把下面的代码:
listView.setNestedScrollingEnabled(true);
隐藏顶部的工具栏,当我滚动列表视图。但是,所有子视图都会移动,包括“浮动操作菜单”。
我希望浮动操作菜单保持空闲,固定在该位置,并且不受NestedScrollingEnabled行为的影响。显然它会影响父视图。
任何解决这个?谢谢。
我的XML大致是这样的(只是忽略附加的图片是从XML代码升技不同,因为它是太长,但总的想法是有):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fragment_price_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e3e3e3">
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipeContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/buttons_selection_container">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="15dp"
android:indeterminateTint="@color/colorProgressBarPrimary"
android:indeterminateTintMode="src_atop"/>
<TextView
android:id="@+id/textView_no_data"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No Price Data"
android:layout_gravity="center_horizontal|center_vertical"
android:textStyle="bold"
android:textSize="18dp"
android:visibility="gone"/>
<ListView
android:id="@+id/listView_prices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="true">
</ListView>
</FrameLayout>
</android.support.v4.widget.SwipeRefreshLayout>
<com.getbase.floatingactionbutton.FloatingActionsMenu
android:id="@+id/price_fragment_float_Menu_button"
android:layout_width="322dp"
android:layout_height="376dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="46dp"
android:layout_marginRight="10dp"
fab:fab_addButtonColorNormal="@color/color_float_blue_dark"
fab:fab_addButtonColorPressed="@color/colorAccent"
fab:fab_addButtonPlusIconColor="@color/white">
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/button_switch_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/color_float_blue_lite"
fab:fab_colorPressed="@color/colorAccent"
fab:fab_icon="@drawable/button_different_currencies"
fab:fab_size="mini"
fab:fab_title="Switch Price"/>
</com.getbase.floatingactionbutton.FloatingActionsMenu>
</RelativeLayout>
在另一个视图中创建浮动按钮并包含您的布局 – Vadivel
使用[Google FAB按钮](https://guides.codepath.com/android/floating-action-buttons)而不是自定义按钮。 –