Is It Possible To Implement Bottom Tab Bar Functionality Like Ios In Android?
In iOS , bottom tab bar functionality is very basic. But in android , I can't implement this functionality. My idea is as follows. Tab bar contains SMS, Call, Camera - 3 tab bar ic
Solution 1:
put this in the XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/home_background_color"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/white"
app:tabPadding="10dp"
android:minHeight="100dp"
app:tabGravity="fill"
app:tabIndicatorColor="@color/app_primary_color"
app:tabMode="fixed"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
and this in the code
try
{
tabLayout.addTab(tabLayout.newTab());
tabLayout.addTab(tabLayout.newTab());
tabLayout.addTab(tabLayout.newTab());
tabLayout.addTab(tabLayout.newTab());
tabLayout.getTabAt(0).setIcon(R.drawable.tab_icon1);
tabLayout.getTabAt(1).setIcon(R.drawable.tab_icon2);
tabLayout.getTabAt(2).setIcon(R.drawable.tab_icon3);
tabLayout.getTabAt(3).setIcon(R.drawable.tab_icon4);
}
catch (Exception e)
{
Log.e("TabLayout Creation Error",e.getMessage());
}
tabLayout.setOnTabSelectedListener(newTabLayout.OnTabSelectedListener() {
@OverridepublicvoidonTabSelected(TabLayout.Tab tab) {
switch(tabLayout.getSelectedTabPosition())
{
case0:
break;
case1:
//Do the stuffbreak;
case2:
//Do the stuffbreak;
case3:
//Do the stuffbreak;
}
}
@OverridepublicvoidonTabUnselected(TabLayout.Tab tab) {
}
@OverridepublicvoidonTabReselected(TabLayout.Tab tab) {
}
});
Solution 2:
Yes it is possible tab bar in bottom try this
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent" ><TabHostandroid:id="@android:id/tabhost"android:layout_width="match_parent"android:layout_height="match_parent" ><RelativeLayoutandroid:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical" ><FrameLayoutandroid:id="@android:id/tabcontent"android:layout_width="fill_parent"android:layout_height="fill_parent" /><TabWidgetandroid:id="@android:id/tabs"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:divider="@drawable/bg_tab_seperator"android:dividerPadding="0dp" /></RelativeLayout></TabHost>
Solution 3:
I have implemented what youre saying in one my apps..ill post the xm shortly
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_above="@+id/app_bar"/>
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:background="@color/background"
>
<com.****.****.ui.custom.IconTextTabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="@dimen/custom_tab_layout_height"
app:tabGravity="fill"
app:tabMode="fixed" />
</android.support.design.widget.AppBarLayout>
</RelativeLayout>
my <com.****.****.ui.custom.IconTextTabLayout
is nothing but a class which extends TabLayout
you can use the default widget.
Post a Comment for "Is It Possible To Implement Bottom Tab Bar Functionality Like Ios In Android?"