我刚刚在我的activity.xml中添加了DrawerLayout。遇到间距问题......我需要抽屉布局才能坐在主线性布局上方。现在得到一个错误,说:“多根标签”。线性布局上方的DrawerLayout
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/container_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
</LinearLayout>
<FrameLayout
android:id="@+id/container_body"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
<fragment
android:id="@+id/fragment_navigation_drawer"
android:name="com.example.my.app.FragmentDrawer"
android:layout_width="@dimen/nav_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout="@layout/fragment_navigation_drawer"
tools:layout="@layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
获得以下多个根标签错误:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageButton
android:id="@+id/btn_lst_car"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_margin="8dp"
android:background="@android:color/transparent"
android:contentDescription="@null"
android:src="@android:drawable/ic_menu_add" />
<TextView
android:id="@+id/txt_empty_list_cars"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="4dp"
android:gravity="center"
android:text="@string/view1"
android:textAppearance="?android:attr/textAppearance"
android:textColor="@android:color/darker_gray"
android:visibility="gone" />
<ListView
android:id="@+id/list_cars"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/txt_header"
android:layout_margin="4dp"
android:divider="@android:drawable/divider_horizontal_bright"
android:dividerHeight="0.5dp"
android:listSelector="@android:drawable/list_selector_background" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Logout"
android:id="@+id/btnLogout"
android:layout_alignBottom="@+id/txt_header"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
发布logcat的错误 –
一次性发布整个layout.xml,不要分割它。 –
我发布的是整个layout.xml – neo