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

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

问题描述


我已经看到了一些唠叨此事,但不了了之。 有没有办法把标签的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:

一)设置下的FrameLayout维基,tabwidget b)该tabwidget的严重性设置为底部

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

谢谢! llappall

Thanks! llappall

推荐答案

下面是获得在屏幕底部的选项卡最简单,最强大的,可扩展的解决方案。

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

  1. 在垂直的LinearLayout,放的FrameLayout以上TabWidget
  2. 设置 layout_height WRAP_CONTENT 双方的FrameLayout和TabWidget
  3. 设置的FrameLayout的的android:layout_weight =1
  4. 设置TabWidget的的android:layout_weight =0(0为默认值,但对于强调,可读性等)
  5. 设置TabWidget的安卓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)

全部code:

<?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>

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

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