禁用设置SlidingPaneLayout水平滚动

时间:2018-10-12 15:51:15

标签: java android xml

我正在使用SlidingPaneLayout制作“自定义”抽屉菜单,我需要通过单击工具栏导航按钮来禁用可拖动事件以仅显示服装抽屉,我的activity_main的结构为:

主要活动

<android.support.v4.widget.SlidingPaneLayout
    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:id="@+id/slidingPaneLayout"
    android:clickable="false"
    android:scrollbarAlwaysDrawHorizontalTrack="false"
    tools:context=".MainActivity.MainActivity">

    <!--Costume Drawer fragment-->
    <fragment
        android:name="com.epcon.pdhgto.android.MenuFragment.MenuFragment"
        android:layout_width="80dp"
        android:layout_height="match_parent"
        android:id="@+id/menu_master"
        android:elevation="10dp">
    </fragment>
    <!--Fragment-->
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clickable="true"
        android:id="@+id/mainFrameLayout"
        >

    </FrameLayout>

</android.support.v4.widget.SlidingPaneLayout>

换句话说,我需要在主要活动上禁用水平滚动。 我已经尝试过了: https://stackoverflow.com/a/36447209/6308377 ,而且我也已经在我的xml android:scrollbarAlwaysDrawHorizontalTrack上实现了,但这不起作用。

1 个答案:

答案 0 :(得分:0)

在您的主要活动中尝试

view.setHorizontalScrollBarEnabled(false);

或将其放在您的xml文件中

android:scrollbars="none"

此外,如果您想为自己的应用创建自定义菜单,还应该签出导航抽屉

相关问题