Hi I want to display tabs in the bottom of the screen with icon above the text in each tab(similar like zomato),i have tried but i am not getting the icons and text.can you please help me thanks in advance
Asked
Active
Viewed 1,450 times
-2
-
Please post all the things you have tried so far!!! – Shrikant Nov 02 '16 at 07:26
-
I think It is not a tab. I just a menu. – K.Sopheak Nov 02 '16 at 07:35
-
Just add `android:uiOptions="splitActionBarWhenNarrow"` in manifest. See this: http://stackoverflow.com/a/18944930/5241603 – K.Sopheak Nov 02 '16 at 07:42
1 Answers
2
You can use below library to achieve BottomBar
[Update]
Now google released BottomNavigationView to achieve your requirement. This class is a part of support design library. add gradle dependency
compile ‘com.android.support:design:25.0.0’
Add layout file in your xml
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:itemBackground="@color/colorPrimary"
app:itemIconTint="@color/white"
app:itemTextColor="@color/white"
app:menu="@menu/bottom_navigation_main" />
create bottom_navigation_main.xml file which included in above layout.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_favorites"
android:enabled="true"
android:icon="@drawable/ic_favorite_white_24dp"
android:title="@string/text_favorites"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_schedules"
android:enabled="true"
android:icon="@drawable/ic_access_time_white_24dp"
android:title="@string/text_schedules"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_music"
android:enabled="true"
android:icon="@drawable/ic_audiotrack_white_24dp"
android:title="@string/text_music"
app:showAsAction="ifRoom" />
</menu>
and finally use this layout in java class like below
BottomNavigationView bottomNavigationView = (BottomNavigationView)
findViewById(R.id.bottom_navigation);
bottomNavigationView.setOnNavigationItemSelectedListener(
new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.action_favorites:
break;
case R.id.action_schedules:
break;
case R.id.action_music:
break;
}
return false;
}
});

subrahmanyam boyapati
- 2,836
- 1
- 18
- 28