簡體   English   中英

禁用設置SlidingPaneLayout水平滾動

[英]Set SlidingPaneLayout horizontal scroll disabled

我正在使用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上實現了,但這不起作用。

在您的主要活動中嘗試

view.setHorizontalScrollBarEnabled(false);

或將其放在您的xml文件中

android:scrollbars="none"

另外,如果您想為自己的應用制作自定義菜單,則應查看導航抽屜

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM