是否可以在Android中实现iOS之类的底部标签栏功能? [英] Is it possible to implement bottom tab bar functionality like iOS in android?

查看:85
本文介绍了是否可以在Android中实现iOS之类的底部标签栏功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS中,底部的标签栏功能非常基本.但是在android中,我无法实现此功能. 我的想法如下. 标签栏包含短信,通话,摄像头-3个标签栏图标. 每当点击此图标时,我想运行安装在我的android设备上的SMS,电话和摄像头. 但是这些应该与iOS选项卡视图"相同. (不应全屏显示) 我已经找到解决方案很长时间了,但是我找不到正确的方法. 请帮我 谢谢

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 icons. Whenever taps this icons, I want to run SMS, Phone call and Camera installed on my android device. But these should be the same as iOS tab View. (shouldn't be full screen) I have found solution for a long time, but I can't find the correct way. Please help me Thanks

推荐答案

将其放入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" />

以及代码中的

 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(new TabLayout.OnTabSelectedListener() {
        @Override
        public void onTabSelected(TabLayout.Tab tab) {
switch(tabLayout.getSelectedTabPosition())
    {
    case 0:

break;
        case 1:
//Do the stuff
break;
        case 2:
//Do the stuff
break;
        case 3:
//Do the stuff
break;
        }
     }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {

        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {

        }
    });

这篇关于是否可以在Android中实现iOS之类的底部标签栏功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆