Android開源--MenuDrawer

來源:互聯網
上載者:User

標籤:android   style   blog   http   io   color   os   ar   sp   

開源地址:https://github.com/SimonVT/android-menudrawer

簡介:menudrawer是跟sliderMenu差不多的一種架構,常被應用做設定介面,以menu作為設定菜單,contentView作為詳細頁面的架構,如



API詳解:

****************************左邊MenuDrawer***************************************
1.設定首頁
menuDrawer=MenuDrawer.attach(this,MenuDrawer.MENU_DRAG_CONTENT);
menuDrawer.setContentView(R.layout.activity_main);
2.設定Menu頁/高度
menuDrawer.setMenuView(mListView);
menuDrawer.setMenuSize(getWindowManager().getDefaultDisplay().getWidth());
3.主/Menu頁相互跳轉
menuDrawer.toggleMenu();
4.關閉Menu頁
menuDrawer.closeMenu();


5.右邊標示的儲存和滑動:
getView(設定Tag):  v.setTag(R.id.mdActiveViewPosition, position);
OnItemClickListener(設定當前活躍Item):menuDrawer.setActiveView(v,position);


6.滑動時(重新整理指示標示)
mListView.setOnScrollListener(new OnScrollListener() {

@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}

@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
menuDrawer.invalidate();
}
});


7.設定拖動有效地區
menuDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN);


8.第4個參數判斷能否被拖動
menuDrawer=MenuDrawer.attach(this,MenuDrawer.MENU_DRAG_CONTENT,Position.RIGHT,true);


****************************右/上下邊MenuDrawer***************************************
1.設定首頁(第3個參數提供了菜單的4個方向)
menuDrawer=MenuDrawer.attach(this,MenuDrawer.MENU_DRAG_CONTENT, Position.RIGHT);
2.修改指標的位置:
1)在AndroidManifest.xml中修改樣式
android:theme="@style/SampleTheme.Right"
2)在theme.xml中修改:
<style name="SampleBase" parent="@android:style/Theme.Holo.Light" />


<style name="SampleTheme.Right" parent="SampleBase">
   <item name="menuDrawerStyle">@style/MenuDrawerStyle.Right</item>
</style>
3)在style.xml中修改:
<style name="MenuDrawerStyle.Right" parent="Widget.MenuDrawer">
        <item name="mdActiveIndicator">@drawable/menu_arrow_right</item>
        <item name="mdMenuSize">200dp</item>
</style>


****************************自訂MenuDrawer***************************************
XML:
View層必須是net.simonvt.menudrawer.TopDrawer四種中的一種定義
menu頁的id必須為android:id="@id/mdMenu"
首頁的id必須是android:id="@id/mdContent"
代碼:設定手動模式並設定menu寬/高
menuDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN);
menuDrawer.setMenuSize(50);
定義指示位置:(指示標的顯示得由manifest檔案裡面的theme指定)menuDrawer.setActiveView(v);


****************************MenuDrawer+ViewPager***************************************
Tip:1)首頁實現FragmentActivity;
2)在onPageChangeListener中onPageSelected實現:
menuDrawer.setTouchMode(position==0?MenuDrawer.TOUCH_MODE_FULLSCREEN:MenuDrawer.TOUCH_MODE_NONE);



Android開源--MenuDrawer

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.