lla*_*all 148 android tabwidget
我已经看到一些关于这个的喋喋不休,但没有什么明确的.有没有办法将TabWidget中的标签放到屏幕底部?如果是这样,怎么样?
我尝试了以下,但没有奏效:
a)在tablayout下面设置tabwidget
b)将tabwidget的引力设置为"bottom"
谢谢!llappall
sto*_*986 272
这是最简单,最强大,可扩展的解决方案,可以在屏幕底部显示标签.
layout_height为wrap_contentFrameLayout和TabWidget android:layout_weight="1"android:layout_weight="0"(默认为0,但强调,可读性等)android:layout_marginBottom="-4dp"(删除底部分隔符)完整代码:
<?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>
Run Code Online (Sandbox Code Playgroud)
Lea*_*dro 38
试试吧;)只是看的FrameLayout(@ ID/tabcontent)的内容,因为我不知道它将如何在滚动的情况下,处理......对我来说,它的作品,因为我使用的ListView作为我的选项卡的内容.:) 希望能帮助到你.
<?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">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_above="@android:id/tabs" />
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</TabHost>
Run Code Online (Sandbox Code Playgroud)
Bri*_*pin 12
有一种方法可以删除该行.
1)按照本教程: android-tabs-with-fragments
2)然后应用Leaudro上面建议的RelativeLayout更改(将布局道具应用于所有FrameLayouts).
您还可以将ImageView添加到项目#1中的tab.xml,并获得类似于iPhone的标签.
这是我正在进行的工作的截图.我还有一些工作要做,主要是为图标做一个选择器,并确保相等的水平分布,但你明白了.就我而言,我正在使用片段,但相同的主体应该适用于标准选项卡视图.

这可能不完全是您正在寻找的(这不是将选项卡发送到屏幕底部的“简单”解决方案),但仍然是一个有趣的替代解决方案,我想向您指出:
ScrollableTabHost的设计与 TabHost 类似,但具有额外的滚动视图以适应更多项目...
也许深入研究这个开源项目你会找到你的问题的答案。如果我看到任何更容易的事情,我会回来找你。
| 归档时间: |
|
| 查看次数: |
158168 次 |
| 最近记录: |