gpt4 book ai didi

Android:TabHost.TabSpec setIndicator(CharSequence 标签)

转载 作者:行者123 更新时间:2023-11-29 22:30:00 24 4
gpt4 key购买 nike

我正在尝试创建一个选项卡 UI,但我不想在 tabHosts 上放置任何图像,因此我决定使用 setIndicator(CharSequence 标签)而不是使用 setIndicator(CharSequence 标签,Drawable 图标)。然后创建没有图像的 tabHost,但它的高度更小并且仅包含 CharSequence,它与带有图像的常规 tabHost 具有相同的高度。顶部有一个空闲空间,通常位于图像所在的位置,文本位于该空白空间下方。无论如何要删除为图像保留的可用空间,或者翻转两者,以便文本位于顶部,之后我可以将 layout_height 设置为 15dp 例如。主要布局的 .xml 代码是

<?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">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
</LinearLayout>
</TabHost>

最佳答案

您可以将@null 设置为背景,并设置负边距以删除可用空间。

<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginLeft="-2dp"
android:layout_marginRight="-2dp" />

关于Android:TabHost.TabSpec setIndicator(CharSequence 标签),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4459996/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com