Android中的slidingmenu

來源:互聯網
上載者:User

標籤:android   parent   sch   log   height   https   工程   開源   targe   

簡介

SlidingMenu作為滑動側邊欄主要用來代替Android傳統的Menu菜單。

匯入方法

SlidingMEnu以前依賴於另一個開源庫ActionBarSherlock,但是現在被AppCompat代替。只需要匯入SlidingMenu的庫即可,AppCompat-support-v7預設就會匯入工程

具體的:Andriod Studio->File->New->Import Module, 選擇SlidingMenu-master\library,在匯入後需要修改工程的build.gradle中的buildToolsVersion屬性,改為19.1.0以上。

使用方法
slidingMenu = new SlidingMenu(this);slidingMenu.setMode(SlidingMenu.LEFT);slidingMenu.setBehindOffsetRes(R.dimen.sliding_menu_offset);slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);slidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);slidingMenu.setMenu(R.layout.slidingmenu);

  具體每一個API的含義可以參考CTRL+Q的解釋,都比較好理解。

R.layout.slidingmenu是指slidingmenu的布局檔案:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"              android:layout_width="match_parent"              android:layout_height="match_parent"        android:background="#FF999999">    <com.jeremyfeinstein.slidingmenu.lib.SlidingMenu            android:id="@+id/slidingmenulayout"            android:layout_height="match_parent"            android:layout_width="match_parent">        <Button                android:text="Click me"                android:layout_width="match_parent"                android:layout_height="wrap_content">        </Button>    </com.jeremyfeinstein.slidingmenu.lib.SlidingMenu></LinearLayout>

  

R.dimen.sliding_menu_offset是指slidingMenu可以被划出的距離:

<resources>    <!-- Default screen margins, per the Android Design guidelines. -->    <dimen name="sliding_menu_offset">200dp</dimen></resources>

  

Android中的slidingmenu

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.