-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Basic Usage
How to use BMB in just several lines of code?
Add BMB in .xml file.
<com.nightonke.boommenu.BoomMenuButton
android:id="@+id/bmb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
Then in .java file, find your BMB and set some attributes for it.
BoomMenuButton bmb = (BoomMenuButton) findViewById(R.id.bmb);
Set button-enum for BMB, button-enum tells which kind of boom-button(the sub-buttons when booming) that you want.
-
ButtonEnum.SimpleCircle
corresponding to Simple Circle Button -
ButtonEnum.TextInsideCircle
corresponding to Text Inside Circle Button -
ButtonEnum.TextOutsideCircle
corresponding to Text Outside Circle Button -
ButtonEnum.Ham
corresponding to Ham Button
bmb.setButtonEnum(ButtonEnum.SimpleCircle);
Or in .xml:
app:bmb_buttonEnum="simpleCircle"
app:bmb_buttonEnum="textInsideCircle"
app:bmb_buttonEnum="textOutsideCircle"
app:bmb_buttonEnum="ham"
Then you need to tell BMB how it should place pieces on itself. Click the links for 4 kinds of buttons above to check different piece-place-enums.
bmb.setPiecePlaceEnum(PiecePlaceEnum.DOT_3_1);
Or in .xml:
app:bmb_piecePlaceEnum="piecePlace_dot_3_1"
Now tell BMB how to place the buttons on the screen when booming. Click the links for 4 kinds of buttons above to check different button-place-enums.
bmb.setButtonPlaceEnum(ButtonPlaceEnum.SC_3_3);
Or in .xml:
app:bmb_buttonPlaceEnum="buttonPlace_sc_3_3"
You have set attributes for BMB itself, now add builders for customizing boom-buttons to BMB. There are 4 different builders for the 4 kinds of boom-buttons above. For instance, use SimpleCircleButton.Builder
for ButtonEnum.SimpleCircle
. Click the links for 4 kinds of buttons above to find out how to use builders.
for (int i = 0; i < bmb.getButtonPlaceEnum().buttonNumber(); i++) {
bmb.addBuilder(new SimpleCircleButton.Builder()
.normalImageRes(R.drawable.jellyfish));
}
And now your BMB is ready for a boom.
You must keep the number of piece-place-enum, number of button-place-enum and number of builders being the same.
The name of piece-place-enum is XXX_N_M, where XXX is name(DOT or HAM), N is number and M represents different types. Similarly, the name of button-place-enum is YYY_N_M. You must keep the first N equals to the second one. But you needn't keep the two M same(The code above is an example: DOT_3_1 and SC_3_3).
And the number of builders must be N. Any breaking-rules-code will get a runtime exception.
- Basic Usage
- Simple Circle Button
- Text Inside Circle Button
- Text Outside Circle Button
- Ham Button
- Share Style
- Custom Position
- Button Place Alignments
- Different Ways to Boom
- Ease Animations for Buttons
- Different Order for Buttons
- Other Animations Attributes for Buttons
- Click Event and Listener
- Control BMB
- Use BMB in Action Bar
- Use BMB in Tool Bar
- Use BMB in List
- Use BMB in Fragment
- Attributes for BMB or Pieces on BMB
- Cache Optimization & Boom Area
- Change Boom Buttons Dynamically
- Fade Views
- Version History
- Structure for BMB