gpt4 book ai didi

android - Tabhost 标题被裁掉

转载 作者:太空宇宙 更新时间:2023-11-03 12:57:19 24 4
gpt4 key购买 nike

这是我的xml文件

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
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"
android:gravity="center" >
</TabWidget>

<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</FrameLayout>
</LinearLayout>

</TabHost>

这是我的.class文件

    TabHost tabHost = getTabHost();

TabSpec ta1= tabHost.newTabSpec("title");
ta1.setIndicator("title");
Intent ta1intent = new Intent(this, 1_webview.class);
ta1.setContent(ta1intent);

TabSpec ta2= tabHost.newTabSpec("title1");
ta2.setIndicator("Title1");
Intent ta2intent = new Intent(this, 2_webview.class);
ta2.setContent(ta2intent);

TabSpec ta3= tabHost.newTabSpec("two linetitle");
ta3.setIndicator("Two line title");
Intent ta3intent = new Intent(this, 3_webview.class);
ta3.setContent(ta3intent);

TabSpec ta4 = tabHost.newTabSpec("two line title");
ta4.setIndicator("Two line //n title"); //tried using line break displays Two line \N title
Intent ta4intent = new Intent(this, week_webview.class);
ta4.setContent(ta4intent);

这是我得到的

output image

有什么方法可以让我在 tab3 和 tab4 中的标题多行显示而不是被裁掉,tab3 和 tab4 中的实际文本是“双行文本”,但它只显示两行。

或者有没有办法减小字体大小以便所有单词都可见?

最佳答案

也许标题有足够的空间,但 TabView 中的填充太大。

在我的例子中,标题足够短以适合 API-8 到 API-14 的选项卡,但不适合 API-17。删除填充解决了我的问题。

将 5 个选项卡添加到我的 tabHost 后,我​​执行以下操作:

    for (int i=0; i<5; i++) {
View tabView = tabHost.getTabWidget().getChildTabViewAt(i);
tabView.setPadding(0, 0, 0, 0);
TextView tv = (TextView)tabView.findViewById(android.R.id.title);
tv.setSingleLine();
tv.setTextSize(14);
}

关于android - Tabhost 标题被裁掉,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17668756/

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