coolMenu 一款酷炫的 Android 卡片菜單

yimaowu 8年前發布 | 12K 次閱讀 安卓開發 Android開發 移動開發

來自: http://finalshares.com/read-6792

coolMenu 一款酷炫的 Android 卡片菜單

源碼: https://github.com/DxTT/coolMenu

This is Gal Shir's awesome shot.

Usage

I published the library with Jitpack , so add it to your build.gradle with:

repositories {
    ...
    maven { url "https://jitpack.io" }
}

Add the dependency:

dependencies {
    compile 'com.github.DxTT:coolMenu:v1.1'
}

The usage is really like ViewPager , just add  CoolMenuFrameLayout to your layout.

An example of basic usage in layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<merge
    xmlns:android="

<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></pre>

This statement declares the number of cards, The upper limit is five.

app:num="four"

You can set your title icon or title style in xml like this:

app:titleSize="@dimen/cl_title_size"
app:titleColor="@color/colorPrimary"
app:titleIcon="@drawable/menu"

Like ViewPager ,set an Adapter for the  CoolMenuFrameLayout view.

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);</pre>

Contributors

@xuechister , @foocoder

License

coolMenu is available under the MIT license

</div>

 本文由用戶 yimaowu 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!