【问题标题】:how to scroll over range of floating action menu如何滚动浮动操作菜单的范围
【发布时间】:2018-05-13 10:56:15
【问题描述】:

红色区域是scrollView,蓝色区域是浮动操作菜单。

问题是,如果我触摸蓝色区域,我将无法滚动。

我想在任何地方滚动滚动视图,绿色区域或蓝色区域。

我该如何解决这个问题。

这是MainActivity代码的xml文件。

<FrameLayout
    android:id="@+id/frameLayout"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="8">

    <android.support.v4.view.ViewPager
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </android.support.v4.view.ViewPager>


    <com.github.clans.fab.FloatingActionMenu
        android:id="@+id/fam"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="16dp">

        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/fab_qr"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@android:drawable/ic_menu_edit"
            app:fab_label="QR코드"/>

        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/fab_address"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@android:drawable/ic_menu_add"
            app:fab_label="연락처로 추가"/>


        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/fab_id"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@android:drawable/ic_menu_delete"
            app:fab_label="카카오톡 ID로 추가"/>


        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/fab_recommend"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@android:drawable/ic_menu_delete"
            app:fab_label="추천친구"/>

    </com.github.clans.fab.FloatingActionMenu>

</FrameLayout>

viewPager的代码

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="친구"/>

    <!--<ListView-->
        <!--android:id="@+id/listView"-->
        <!--android:layout_width="match_parent"-->
        <!--android:layout_height="match_parent">-->
    <!--</ListView>-->
    <com.example.kakaotalk3.NonScrollListView

        android:id="@+id/listView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </com.example.kakaotalk3.NonScrollListView>

</LinearLayout>

【问题讨论】:

    标签: android scroll overlap floating-action-menu


    【解决方案1】:

    类似的问题已经是reported here。请看一看。

    我引用了该问题中报告的问题和解决方案。

    我找到了导致此问题的原因。在我的代码中,它是 onClick 监听器 所有 fab_menu。即使关闭 fab 菜单,它也会覆盖所有触摸。所以 如果你需要这个监听器,你需要在 fab 时手动打开监听器 菜单打开并在关闭时关闭侦听器。我删除后 侦听器 fab 菜单效果很好。

    因此,我想建议像下面这样覆盖onMenuToggleListener,并在菜单处于关闭状态时禁用您的晶圆厂按钮上的点击监听器。

    fabMenu.setOnMenuToggleListener(new FloatingActionMenu.OnMenuToggleListener() {
        @Override
        public void onMenuToggle(boolean opened) {
            if (opened) {
    
            } else {
    
            }
        }
    });
    

    希望有帮助!

    【讨论】:

      【解决方案2】:

      确保您没有在 fab 菜单上注册点击监听器

      like - fabm.setOnClickListener(this);

      如果你注册然后删除它,希望它会正常工作!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-11-23
        • 2015-12-21
        • 1970-01-01
        • 1970-01-01
        • 2016-07-26
        • 2018-01-12
        相关资源
        最近更新 更多