如何添加LinearLayout与行imageView在导航抽屉



你好,我有以下布局文件:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <!-- The main content view -->
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <!-- Add The mainmenu-->
    // add a linearLayout with 3 row of imagaeView
    <!-- The navigation drawer -->
    <Mvx.MvxListView
        local:MvxBind="ItemsSource MenuItems; ItemClick SelectMenuItemCommand"
        local:MvxItemTemplate="@layout/item_menu"
        android:id="@+id/left_drawer"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp"
        android:choiceMode="singleChoice"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="#111" />
</android.support.v4.widget.DrawerLayout>

问题:

  • 如何使用MvxListView在此导航抽屉中添加多行线性布局

左侧为NavigationDrawer

问题:

    必须使用FrameLayout吗?
  1. 可以用LinearLayout代替FrameLayout

DrawerLayout只支持两个子视图。

第一个元素必须始终是内容视图,第二个元素将是抽屉中的内容,并且您必须指定一个重力,表明抽屉是从左边还是从右边进来的。

如果你想在抽屉里有多个ListView,只需在另一个布局中包装内容,如RelativeLayout, FrameLayoutLinearLayout:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <!-- The main content view -->
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <!-- The navigation drawer -->
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="240dp"
        android:layout_gravity="start"
        android:layout_height="match_parent">
        <!-- add other views here -->
        <Mvx.MvxListView
            local:MvxBind="ItemsSource MenuItems; ItemClick SelectMenuItemCommand"
            local:MvxItemTemplate="@layout/item_menu"
            android:id="@+id/left_drawer"
            android:divider="@android:color/transparent"
            android:dividerHeight="0dp"
            android:choiceMode="singleChoice"
            android:layout_width="match_parent"
            android:layout_height="0"
            android:layout_weight="1"
            android:background="#111" />
    </LinearLayout>
</android.support.v4.widget.DrawerLayout>

最新更新