卡片菜單Android版:coolMenu
卡片菜單Android版,由Gal Shir的概念設計而來。
使用說明:
這個library是用 Jitpack發布的,所以在 build.gradle 中添加:
repositories { ... maven { url "https://jitpack.io" } }
添加依賴:
dependencies { compile 'com.github.DxTT:coolMenu:v1.1' }
使用方法類似ViewPager,只需把CoolMenuFrameLayout添加到布局。
在layout.xml中使用的基本例子:
<?xml version="1.0" encoding="utf-8"?> <merge 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" tools:context="com.foocoder.coolmenu.MainActivity" tools:ignore="all" tools:showIn="@layout/activity_main"> <com.dxtt.coolmenu.CoolMenuFrameLayout android:id="@+id/rl_main" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" app:num="four"/> </merge>
這個聲明的是卡片的數目,最多5個:
app:num="four"
Like ViewPager,set an Adapter for the CoolMenuFrameLayout view.
就如ViewPager一樣,為CoolMenuFrameLayout設置一個Adapter:
coolMenuFrameLayout = $(R.id.rl_main); String[] titles = {"CONTACT", "ABOUT", "TEAM", "PROJECTS"}; titleList = Arrays.asList(titles); //set your titles,which is optional coolMenuFrameLayout.setTitles(titleList); //set your menu icon coolMenuFrameLayout.setMenuIcon(R.drawable.menu2); fragments.add(new Fragment1()); fragments.add(new Fragment2()); fragments.add(new Fragment3()); fragments.add(new Fragment4()); FragmentPagerAdapter adapter = new FragmentPagerAdapter(getSupportFragmentManager()) { @Override public Fragment getItem(int position) { return fragments.get(position); } @Override public int getCount() { return fragments.size(); } }; coolMenuFrameLayout.setAdapter(adapter);
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!