这两天发现了一个比较实用,有比较酷炫的Menu(菜单),BoomMenu库工程。
这里有我搜集的各种酷炫的关于Menu的:http://blog.csdn.net/qq_34501274/article/details/53837454
先上效果图:
BoomMenu的引用
compile 'com.nightonke:boommenu:2.0.4'
或
<dependency>
<groupId>com.nightonke</groupId>
<artifactId>boommenu</artifactId>
<version>2.0.4</version>
<type>pom</type>
</dependency>
BoomMenu文档观看步骤
1.打开这个项目的github地址:https://github.com/Nightonke/BoomMenu
2.找到wiki,根据你自己喜欢的样式,去选择看对应的文档使用说明
3.这里选择了Text Outside Circle Button
在这里会看到相关的使用步骤
使用步骤
1.xml的配置
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_control"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<com.nightonke.boommenu.BoomMenuButton
android:id="@+id/bmb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
app:bmb_buttonEnum="textOutsideCircle"
app:bmb_piecePlaceEnum="piecePlace_dot_2_1"
app:bmb_buttonPlaceEnum="buttonPlace_sc_2_1"
app:bmb_boomInWholeScreen="false"
/>
</FrameLayout>
</LinearLayout>
注意
app:bmb_buttonEnum="textOutsideCircle"
app:bmb_piecePlaceEnum="piecePlace_dot_2_1"
app:bmb_buttonPlaceEnum="buttonPlace_sc_2_1"
app:bmb_boomInWholeScreen="false"
每种样式,这些属性对应的是不一样的,一定要使用哪种风格样式,去看对应样式的文档介绍。
2.代码的实现
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
boomMenuButton = (BoomMenuButton) findViewById(R.id.bmb);
for (int i = 0; i < boomMenuButton.getPiecePlaceEnum().pieceNumber(); i++) {
TextOutsideCircleButton.Builder builder = new TextOutsideCircleButton.Builder()
.listener(new OnBMClickListener() {
@Override
public void onBoomButtonClick(int index) {
Toast.makeText(MainActivity.this, "Clicked " + index, Toast.LENGTH_SHORT).show();
}
})
.normalImageRes(getImageResource())
.normalText(getext());
boomMenuButton.addBuilder(builder);
}
}
private static int index = 0;
static String getext() {
if (index >= text.length) index = 0;
return text[index++];
}
private static String [] text = new String[]{"111111","2222222"
};
private static int imageResourceIndex = 0;
static int getImageResource() {
if (imageResourceIndex >= imageResources.length) imageResourceIndex = 0;
return imageResources[imageResourceIndex++];
}
private static int[] imageResources = new int[]{
R.drawable.bat,
R.drawable.bear,
// R.drawable.bee,
// R.drawable.butterfly,
// R.drawable.cat,
// R.drawable.deer,
// R.drawable.dolphin,
// R.drawable.eagle,
// R.drawable.horse,
// R.drawable.jellyfish,
// R.drawable.owl,
// R.drawable.peacock,
// R.drawable.pig,
// R.drawable.rat,
// R.drawable.snake,
// R.drawable.squirrel
};
看效果图,我这里设置了两个图片,是根据上面需要 ##注意##
的属性来设置的。
就是下面这两个属性:
app:bmb_piecePlaceEnum="piecePlace_dot_2_1"
app:bmb_buttonPlaceEnum="buttonPlace_sc_2_1"
做完上面这些就已经完成了,是不是很简单!只需要三步就ok了, 主要还比较实用,非常值得学习的! 里面还有很多炫酷的效果,有兴趣的可以去学习下!
BoomMenu github地址:https://github.com/Nightonke/BoomMenu
demo下载地址:http://download.csdn.net/detail/qq_34501274/9719661