UI框架之FilterMenu使用

28 篇文章 0 订阅
6 篇文章 0 订阅

项目Git地址:https://github.com/lantian0314/ndkDemo

UI框架FilterMenu是一种Menu界面,如下图


第一、配置build.gradle文件

 compile 'com.linroid.filtermenu:library:0.2.+@aar'

第二、Layout界面布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:custom="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.linroid.filtermenu.library.FilterMenuLayout
        android:id="@+id/filter_menu"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:elevation="8dp"
        custom:fm_expandedRadius="96dp"
        custom:fm_collapsedRadius="24dp"
        custom:fm_centerBottom="50dp"
        custom:fm_centerRight="50dp"
        custom:fm_primaryColor="#ff37aa4a"
        custom:fm_primaryDarkColor="#ff20622b">
    </com.linroid.filtermenu.library.FilterMenuLayout>
</LinearLayout>

第三、Activity布局

public class MFilterMenu extends AppCompatActivity {
    @BindView(R.id.filter_menu)
    FilterMenuLayout filterMenuLayout;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.filtermenu);
        ButterKnife.bind(this);
        FilterMenu filterMenu = new FilterMenu.Builder(this).addItem(R.drawable.icon1).addItem(R.drawable.icon1).addItem(R.drawable.icon1).attach(filterMenuLayout).withListener(new FilterMenu.OnMenuChangeListener() {
            @Override
            public void onMenuItemClick(View view, int position) {
                switch (position) {
                    case 0:
                        Toast.makeText(getApplicationContext(),"点击position:"+position,Toast.LENGTH_SHORT).show();
                        break;
                    case 1:
                        Toast.makeText(getApplicationContext(),"点击position:"+position,Toast.LENGTH_SHORT).show();
                        break;
                    default:
                        Toast.makeText(getApplicationContext(),"点击position:"+position,Toast.LENGTH_SHORT).show();
                        break;
                }
            }

            @Override
            public void onMenuExpand() {

            }

            @Override
            public void onMenuCollapse() {

            }
        }).build();

//        <!--circle radius size when menu expanded-->
//                custom:fm_expandedRadius
//                <!--circle radius size when menu collapsed-->
//                custom:fm_collapsedRadius
//                <!--set the position of circle, the menu will auto align.
//        You should only set two directions at most.-->
//                custom:fm_center[Left|Top|Right|Bottom]
//                <!-- If true, centers the circle horizontally.-->
//                custom:fm_centerHorizontal
//                <!-- If true, centers the circle vertically.-->
//                custom:fm_centerVertical
//                <!--primary color-->
//                custom:fm_primaryColor
//                <!--color of inner circle when menu expanded-->
//                custom:fm_primaryDarkColor
    }
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值