Giter VIP home page Giter VIP logo

expendmenu's Introduction

ExpendMenu

用FloatingActionButton实现展开菜单 效果图如下:

效果图

使用方法:

在XML文件中,这个父类是FloatingActionButton:

    <com.ice.view.UnfoldButton
        android:id="@+id/unfoldButton"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginRight="20dp"
        android:layout_marginBottom="18dp"
        app:elevation="5dp"
        app:borderWidth="0dp"
        android:layout_gravity="right"
        android:src="@drawable/add"
        android:background="@color/colorAccent"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true" />

在Activity中:

        UnfoldButton f = (UnfoldButton) findViewById(R.id.unfoldButton);

        //第一个是菜单图标  第二个是菜单背景颜色  第三个是点击回调
        f.addElement(R.drawable.ic_menu_share,R.color.blue, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //这里写菜单的点击事件
                Toast.makeText(UnfoldButtonActivity.this, "点击了", Toast.LENGTH_SHORT).show();
            }
        });
        f.addElement(R.drawable.ic_menu_gallery,R.color.green,null);
        f.addElement(R.drawable.ic_menu_send,R.color.grey,null);
        f.setAngle(90);//这个是展开的总角度  建议取90的倍数
        f.setmScale(1);//设置弹出缩放的比例  1为不缩放 范围是0—1
        f.setLength(250);//设置弹出的距离

弹出菜单后,背景颜色由你自己定,你需要在colors.xml里面声明一个color: <color name="background">#9b414141</color> name必须是background

好了,这样就可以啦!

expendmenu's People

Contributors

chnicelee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.