先放效果圖

menu.gif
- 按鈕的圖片和顏色可自定義。
- 可以設(shè)置點(diǎn)擊事件
這么炫酷的效果怎么實(shí)現(xiàn)呢? 只需3步!
How to use
Step1
引入依賴
allprojec
ts {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.monkeywiiu:Xmenu:v5'
}
Step2
使用自定義控件(其實(shí)就是一個(gè)RelativeLayout)
<com.example.zmenu.SnakeButtonLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.example.zmenu.SnakeButtonLayout>
just like RelativeLayout
Step3
//設(shè)置圖片和顏色
PUtils.getInstance().setImagesAndColors(List<Integer> imageList, List<Integer> colorList);
//設(shè)置是否可見(jiàn),默認(rèn)是不可見(jiàn)
PUtils.getInstance().setVisible(true);
//設(shè)置懸浮按鈕的margin
PUtils.getInstance().setMargin((int) getResources().getDimension(R.dimen.marginRight),
(int) getResources().getDimension(R.dimen.marginBottom));
setContentView(R.layout.activity_main);
- 需要在
setContentView(..)之前設(shè)置圖片和顏色
設(shè)置按鈕的點(diǎn)擊事件
container.setIsClickable(true); //默認(rèn)是false
container = (SnakeButtonLayout) findViewById(R.id.container);
container.setOnTopViewClickListener(new SnakeButtonLayout.onTopViewClickListener() {
@Override
public void onclick() {
Toast.makeText(MainActivity.this, "你點(diǎn)擊了導(dǎo)航欄", Toast.LENGTH_SHORT).show();
}
});
github地址:https://github.com/monkeywiiu/Xmenu
喜歡記得star一下唄