【发布时间】:2015-09-08 08:03:11
【问题描述】:
我正在尝试构建 tabhost 编码,但我被困在 .xml 部分。
以下是activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/pager"
android:layout_width="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity" />
<android.support.v4.app.FragmentTabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</android.support.v4.app.FragmentTabHost>
有人知道这个版本的问题吗?
消息 “错误:(8) 解析 XML 时出错:文档元素后出现垃圾” 出现在 第 7 行。 希望有人知道这个问题并可以帮助我,非常感谢...!!
【问题讨论】:
-
在 Viewpager 上方设置一个根布局,如相对或线性
-
您似乎有两个根元素 -
ViewPager和FragmentTabHost。那是无效的。你的意思是FragmentTabHost元素在insideViewPager元素吗? -
我明白了,谢谢。我意识到最后没有包含viewpager root
标签: java android xml android-layout