android炫酷的導(dǎo)航欄效果

先放效果圖

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一下唄

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容