Android:底部的标签 [英] Android: Tabs at the BOTTOM

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

问题描述

我看到过一些关于这个的讨论,但没有确定.有没有办法将 TabWidget 中的选项卡放在屏幕底部?如果是,怎么办?

I've seen some chatter about this, but nothing definite. Is there a way to put the tabs in a TabWidget to the bottom of the screen? If so, how?

我尝试了以下方法,但没有奏效:

I've tried the following, but didn't work:

a) 在框架布局下方设置 tabwidget
b) 将 tabwidget 的重力设置为底部"

a) setting the tabwidget below the framelayout
b) setting the tabwidget's gravity to "bottom"

谢谢!拉帕尔

推荐答案

这是在屏幕底部获取选项卡的最简单、最强大且可扩展的解决方案.

Here's the simplest, most robust, and scalable solution to get tabs on the bottom of the screen.

  1. 在您的垂直 LinearLayout 中,将 FrameLayout 放在 TabWidget 上方
  2. 在 FrameLayout 和 TabWidget 上将 layout_height 设置为 wrap_content
  3. 设置FrameLayout的android:layout_weight="1"
  4. 设置 TabWidget 的 android:layout_weight="0"(0 是默认值,但为了强调、可读性等)
  5. 设置TabWidget的android:layout_marginBottom="-4dp"(去除底部分隔线)
  1. In your vertical LinearLayout, put the FrameLayout above the TabWidget
  2. Set layout_height to wrap_content on both FrameLayout and TabWidget
  3. Set FrameLayout's android:layout_weight="1"
  4. Set TabWidget's android:layout_weight="0" (0 is default, but for emphasis, readability, etc)
  5. Set TabWidget's android:layout_marginBottom="-4dp" (to remove the bottom divider)

完整代码:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp"
            android:layout_weight="1"/>

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0"
            android:layout_marginBottom="-4dp"/>

    </LinearLayout>

</TabHost>

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

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