标签栏隐藏Android的问题 [英] tab bar hiding issue android

查看:97
本文介绍了标签栏隐藏Android的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新到Android,我使用tabHost添加一些标签给它,它的工作相当的精细,但是当我在横向模式下转动我的设备也那里工作很好,但我不需要,因为它有标签栏占地面积大的空间,我也有谷歌广告,让他们两个覆盖半个屏幕,并留下供用户interact.All一点空间我需要的是某种方式隐藏标签栏就像我们可以做到这一点在iPhone做出的解决方案位空间用户interact.I需要一些解决方案urgent.Thanks

I'm new to android,I'm using tabHost adding some tabs to it,its working quite fine but when i rotate my device in landscape mode it also work there fine but i don't need tab bar there because it covers much space and i also have google ads so both of them cover half of the screen and leave a little space for user to interact.All i need is a solution to somehow hide tab bar just like we can do it in iphone to make a bit room for user to interact.I need some solution urgent.Thanks

推荐答案

我觉得你应该换在任何一个ViewGroup如的LinearLayout或RelativeLayout的你的标签窗口小部件,并在tabActivity显示/隐藏此包装创建静态函数,这里的一点点code可能对你有所帮助。

I think you should wrap your tab widget in any ViewGroup such as LinearLayout or RelativeLayout, and create a static function in your tabActivity to show/hide this wrapper, Here's a little code might be helpful for you.

<LinearLayout
        android:id="@+id/popupTabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:visibility="gone">
        <TabWidget android:id="@android:id/tabs"
        android:layout_height="wrap_content" 
        android:layout_width="fill_parent"></TabWidget>
    </LinearLayout>

现在您的标签活动应该做这样的事情。

Now your tab activity should do something like this.

public class TabsView extends TabActivity { 
    public static LinearLayout popupTabs ;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        popupTabs = (LinearLayout) findViewById(R.id.popupTabs);

        // Your other code
        //............
        //............
    }

    // Show Tabs method
    public static void showTabs(){
        popupTabs.setVisibility(ViewGroup.VISIBLE);
    }

    // Hide Tabs method
    public static void hideTabs(){
        popupTabs.setVisibility(ViewGroup.GONE);
    }

}

现在,您可以静态地从任何位置在code这样的调用此方法

Now you can call this method statically from any location in your code like this

// hide tab from any activity
TabsView.showTabs();

// hide tab from any activity
TabsView.hideTabs()

这篇关于标签栏隐藏Android的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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