【问题标题】:Is there any way to locate the tabs on the left hand side of the screen?有没有办法找到屏幕左侧的选项卡?
【发布时间】:2011-10-03 19:03:52
【问题描述】:

我跟着android developers tutorial成功创建了标签。但似乎没有直接的方法可以在设备屏幕的左侧找到标签

有没有人知道实现左侧标签的方法?有没有这方面的指导方针?

【问题讨论】:

    标签: android android-layout android-emulator android-widget android-ndk


    【解决方案1】:

    不,没有。我也搜索过从右到左的支持,但在 Android 中没有这样的东西。

    我所做的是操纵代码,以便用户感觉从右到左 - 我在 XML 中创建了 3 个选项卡,并将代码添加到我的活动中:

        final TabHost tabs = (TabHost) this.findViewById(R.id.tabhost);
        tabs.setup();
        TabHost.TabSpec spec;
        final Resources resources = this.getResources();
    
        // third tab (first from left)
        spec = tabs.newTabSpec("tag3");
        spec.setContent(R.id.aboutImg);
        spec.setIndicator(this.getString(R.string.title_about), resources.getDrawable(R.drawable.id));
        tabs.addTab(spec);
    
        // second tab
        spec = tabs.newTabSpec("tag2");
        spec.setContent(R.id.listfav);
        spec.setIndicator(this.getString(R.string.title_favorites), resources.getDrawable(R.drawable.bdge));
        tabs.addTab(spec);
    
        // first tab
        spec = tabs.newTabSpec("tag1");
        spec.setContent(R.id.viewflipper);
        spec.setIndicator(this.getString(R.string.title_main), resources.getDrawable(R.drawable.cab));
        tabs.addTab(spec);
    
        tabs.setCurrentTab(2);
    

    注意最后一行 - 我将当前选项卡设置为最后一个 - 从右起第一个。

    【讨论】:

      猜你喜欢
      • 2011-09-26
      • 2022-06-15
      • 2023-03-19
      • 2015-08-22
      • 2014-08-04
      • 2019-10-08
      • 1970-01-01
      • 2020-08-01
      • 2021-11-19
      相关资源
      最近更新 更多