-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Use BMB in Action Bar
Weiping Huang edited this page Mar 28, 2017
·
3 revisions
How to put BMB in action bar?
BMB is easy to use in action bar to act as a menu button. Check the demo for more details.
- Create a Custom Action Bar. Firstly, we need a xml file for our custom-action-bar:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@android:color/transparent">
<com.nightonke.boommenu.BoomMenuButton
android:id="@+id/action_bar_left_bmb"
android:layout_width="56dp"
android:layout_height="56dp"
app:bmb_backgroundEffect="false"/>
<TextView
android:id="@+id/title_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:textAllCaps="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:layout_toRightOf="@+id/action_bar_left_bmb"
android:layout_toEndOf="@+id/action_bar_left_bmb"
/>
<com.nightonke.boommenu.BoomMenuButton
android:id="@+id/action_bar_right_bmb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
app:bmb_backgroundEffect="false"
app:bmb_boomEnum="boomParabola_2"/>
</RelativeLayout>
Notice that in action bar, we must remove the background of bmb. To do that, use app:bmb_backgroundEffect="false"
or bmb.setBackgroundEffect(false);
in java file.
- Use Custom-Action-Bar in Activity.
In onCreate
method in activity:
ActionBar mActionBar = getSupportActionBar();
assert mActionBar != null;
mActionBar.setDisplayShowHomeEnabled(false);
mActionBar.setDisplayShowTitleEnabled(false);
LayoutInflater mInflater = LayoutInflater.from(this);
View actionBar = mInflater.inflate(R.layout.custom_actionbar, null);
TextView mTitleTextView = (TextView) actionBar.findViewById(R.id.title_text);
mTitleTextView.setText(R.string.app_name);
mActionBar.setCustomView(actionBar);
mActionBar.setDisplayShowCustomEnabled(true);
((Toolbar) actionBar.getParent()).setContentInsetsAbsolute(0,0);
BoomMenuButton leftBmb = (BoomMenuButton) actionBar.findViewById(R.id.action_bar_left_bmb);
BoomMenuButton rightBmb = (BoomMenuButton) actionBar.findViewById(R.id.action_bar_right_bmb);
- Finally Customize BMBs.
Customize bmbs as we do it before:
leftBmb.setButtonEnum(ButtonEnum.TextOutsideCircle);
leftBmb.setPiecePlaceEnum(PiecePlaceEnum.DOT_9_1);
leftBmb.setButtonPlaceEnum(ButtonPlaceEnum.SC_9_1);
for (int i = 0; i < leftBmb.getPiecePlaceEnum().pieceNumber(); i++)
leftBmb.addBuilder(BuilderManager.getTextOutsideCircleButtonBuilder());
rightBmb.setButtonEnum(ButtonEnum.Ham);
rightBmb.setPiecePlaceEnum(PiecePlaceEnum.HAM_4);
rightBmb.setButtonPlaceEnum(ButtonPlaceEnum.HAM_4);
for (int i = 0; i < rightBmb.getPiecePlaceEnum().pieceNumber(); i++)
rightBmb.addBuilder(BuilderManager.getHamButtonBuilder());
Now your bmb in action bar is ready for a boom.
- 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