如何在 NavigationDrawer 中添加带有 imageView 行的 LinearLayout
How to add LinearLayout with rows of imageView In NavigationDrawer
您好,我有以下布局文件:
<?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 将具有多行的 linearLayout 添加到这个导航抽屉中。
NavigationDrawer
在左边。
问题:
- 我必须使用
FrameLayout
吗?
- 我可以用
LinearLayout
替换 FrameLayout
吗?
DrawerLayout
仅支持两个子视图。
第一个元素必须始终是内容视图,第二个元素是抽屉中的内容,并且您必须指定一个指示抽屉是从左侧还是右侧进入的引力。
如果您想要抽屉中的内容不止 ListView
,只需将内容包装在其他布局中,例如 RelativeLayout
、FrameLayout
或 LinearLayout
:
<?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>
您好,我有以下布局文件:
<?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 将具有多行的 linearLayout 添加到这个导航抽屉中。
NavigationDrawer
在左边。
问题:
- 我必须使用
FrameLayout
吗? - 我可以用
LinearLayout
替换FrameLayout
吗?
DrawerLayout
仅支持两个子视图。
第一个元素必须始终是内容视图,第二个元素是抽屉中的内容,并且您必须指定一个指示抽屉是从左侧还是右侧进入的引力。
如果您想要抽屉中的内容不止 ListView
,只需将内容包装在其他布局中,例如 RelativeLayout
、FrameLayout
或 LinearLayout
:
<?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>