gpt4 book ai didi

Android:布局不显示为选项卡内容

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

我有一些基于布局的选项卡,它们有自己的 xml 描述,但是当我尝试设置选项卡内容时,我得到了这样的结果:

http://img266.imageshack.us/img266/1787/appnavihist.jpg

(带有文本的白色字段是 home.xml 布局的一部分)。这是一些代码:

    TabSpec spec = tabHost.newTabSpec("home").setIndicator("Home").setContent(R.id.LinearLayout_home);
tabHost.addTab(spec);

主.xml:

<?xml version="1.0" encoding="utf-8"?>  

<LinearLayout android:id="@+id/LinearLayout_root" 
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</TabWidget>

<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include layout="@layout/home"/>
</FrameLayout>

</LinearLayout>

最佳答案

我认为你的问题是包含 tabwidget 元素的布局,尝试将 android:orientation="vertical" 属性添加到 tabwidget 容器:

<LinearLayout android:id="@+id/LinearLayout_root" 
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">

TabActivity 的默认 android 模板如下所示:

<TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost"
android:layout_width="match_parent" android:layout_height="match_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent" android:layout_height="match_parent">
<TabWidget android:id="@android:id/tabs" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_weight="0" />
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="match_parent" android:layout_height="0dip"
android:layout_weight="1"/>
</LinearLayout>
</TabHost>

我想它也应该对你有用。

关于Android:布局不显示为选项卡内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4067703/

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