I don't want to show text with icons in bottom bar ? How do i accomplish the same ?
maybe try to put " " in the title field of the bottombar tabs xml
I have tried the same. In that case the icons is getting vertically aligned.
Do you have a right answer? I want to implement the same thing.
There is a trick that can be used to hide the title and center the icon inside of Tab.
for (int i = 0; i < mBottomBar.getTabCount(); i++) {
BottomBarTab tab = mBottomBar.getTabAtPosition(i);
tab.setGravity(Gravity.CENTER);
View icon = tab.findViewById(com.roughike.bottombar.R.id.bb_bottom_bar_icon);
// the paddingTop will be modified when select/deselect,
// so, in order to make the icon always center in tab,
// we need set the paddingBottom equals paddingTop
icon.setPadding(0, icon.getPaddingTop(), 0, icon.getPaddingTop());
View title = tab.findViewById(com.roughike.bottombar.R.id.bb_bottom_bar_title);
title.setVisibility(View.GONE);
}
@ChaosLeong how do you do that? can you explain in detail? I really need to remove the title below the icons and make them positioned at center.
@huzyrah By reading bb_bottom_bar_item_fixed.xml, we known the <merge /> element as the root view and the icon has paddingTop(with 8dp).
Find that the bb_bottom_bar_item_fixed.xml usages in the BottomBarTab#L118. And the BottomBarTab extends from LinearLayout.
So, if you want to move the icon at center, just change the layout_gravity attribute of the BottomBarTab to center, make the paddingTop of icon equals to paddingBottom, and hide the title. There is the magic. 锛歅
I'm not sure the above explanation can make you understand. Because my English is not good. Hope it help for you.锛氾級
@ChaosLeong so does that mean I have to insert the following code to the BottomBarTab.java ? or where do I put it eaxctly? in which line and in which file? sorry, i'm still a noob at this :'(
` for (int i = 0; i < mBottomBar.getTabCount(); i++) {
BottomBarTab tab = mBottomBar.getTabAtPosition(i);
tab.setGravity(Gravity.CENTER);
View icon = tab.findViewById(com.roughike.bottombar.R.id.bb_bottom_bar_icon);
// the paddingTop will be modified when select/deselect,
// so, in order to make the icon always center in tab,
// we need set the paddingBottom equals paddingTop
icon.setPadding(0, icon.getPaddingTop(), 0, icon.getPaddingTop());
View title = tab.findViewById(com.roughike.bottombar.R.id.bb_bottom_bar_title);
title.setVisibility(View.GONE);
}`
@ChaosLeong do you mind sending me your edited code or solution? I can't seem to fix the issue just yet. I have emailed you about this earlier.
@huzyrah Sorry to check your e-mail so late and misunderstood what you mean about 'Can you explain in detail?'. LOL
Just Place the above code after the initialization code of BottomBar.
public class MainActivity extends AppCompatActivity {
private BottomBar mBottomBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_content);
// setup your BottomBar here
setupBottomBar();
for (int i = 0; i < mBottomBar.getTabCount(); i++) {
BottomBarTab tab = mBottomBar.getTabAtPosition(i);
tab.setGravity(Gravity.CENTER);
View icon = tab.findViewById(com.roughike.bottombar.R.id.bb_bottom_bar_icon);
// the paddingTop will be modified when select/deselect,
// so, in order to make the icon always center in tab,
// we need set the paddingBottom equals paddingTop
icon.setPadding(0, icon.getPaddingTop(), 0, icon.getPaddingTop());
View title = tab.findViewById(com.roughike.bottombar.R.id.bb_bottom_bar_title);
title.setVisibility(View.GONE);
}
}
}
@ChaosLeong I have an error on the setupBottomBar( ); line. Also, the first line of my code on MainActivity.java is quite different from yours because mine is public class MainActivity extends AppCompatActivity implements View.OnClickListener { and yours doesn't have the implements View.OnClickListener . Is yours edited or the original one?
Below is the screenshot of what I did to the MainActivity. java . I tried to follow your codes but somehow it still has error.

Check the code here https://gist.github.com/ChaosLeong/e940f865dd81550c540eb0c0d94824b1.
@ChaosLeong please check your email. I just emailed you a new folder last night.
A duplicate of #373, so closing this one.
Expect to see this with the next release.
Is this functionality in the current release (2.3.1)? If so, how do I remove the titles?
For a single tab title to be disabled, use iconOnly="true" as follows
<tab
id="@+id/item"
icon="@drawable/something"
iconOnly="true"/>
For icon only mode for the entire bottombar, use app:bb_behavior="iconsOnly" instead
<com.roughike.bottombar.BottomBar
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_gravity="bottom"
app:bb_tabXmlResource="@xml/bottombar_tabs"
app:bb_behavior="iconsOnly"/>
Most helpful comment
There is a trick that can be used to hide the title and center the icon inside of Tab.