项目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
}
}