指定抽屉尺寸 - Xamarin Android

时间:2016-04-11 14:00:31

标签: android xamarin.android drawerlayout android-navigation-drawer android-layout-weight

我有一个抽屉在大型设备上正常工作,但在较小的设备上占据整个屏幕,我尝试过使用重量但没有成功,也许我实施错了?代码如下。感谢,谢谢。

没有重量

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fitsSystemWindows="true">

<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_height="match_parent"
android:layout_width="325dp"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/drawer_view" />
</android.support.v4.widget.DrawerLayout>

有重量但仍无法正常工作

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="2"
android:fitsSystemWindows="true">

<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/drawer_view" />
</android.support.v4.widget.DrawerLayout>

1 个答案:

答案 0 :(得分:0)

这是NavgiationView布局代码的完整实现。

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <include
        android:id="@+id/cin7toolbar"
        layout="@layout/toolbar" />
    <FrameLayout
        android:id="@+id/flContentSecure"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>
<android.support.design.widget.NavigationView
    android:id="@+id/navigation1"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    app:headerLayout="@layout/nav_header"
    app:menu="@menu/nav_menu_secure" />
</android.support.v4.widget.DrawerLayout>

希望对你有用。

相关问题