如何在NavigationView底部绘制菜单?

时间:2018-05-22 14:33:32

标签: c# xamarin xamarin.android

是否可以使菜单显示在NavigationView的底部,而不是顶部。

我想我可以在NavigationView内放置任何布局,并绘制一些按钮。但是如果可能的话,我想使用app:menu="@menu/activity_main_drawer"

enter image description here

2 个答案:

答案 0 :(得分:0)

您可以通过创建BottomSheetDialog来实现这一点,它的行为与普通的Android对话框相同,但它会显示在底部。要使BottomSheetDialog最有效,最重要的是将app:layout_behavior="android.support.design.widget.BottomSheetBehavior"添加到root view。因此,基本上创建所需的布局,将该行添加到root view,而不是在代码内创建BottomSheetDialog

       //This is Java code but you can easily convert it to C#
       BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);
       View view = getLayoutInflater().inflate(R.layout.yourLayoutHere, null);
       bottomSheetDialog.setContentView(view);
       bottomSheetDialog.show();

答案 1 :(得分:0)

You can use following code to create custom navigation drawer.

    <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:openDrawer="end">

<include layout="@layout/content_home" />

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start">

    <include layout="@layout/layout_navigation" />

</android.support.design.widget.NavigationView>

</android.support.v4.widget.DrawerLayout>

Where `<include layout="@layout/layout_navigation" />` is the custom layout 
for a menu where you can create a custom layout and add required textviews. 
And then you can give gravity bottom to the parent of those textviews.

let me know if this doesn't help.