抽屉物品未占整个宽度

时间:2018-01-10 12:14:33

标签: android navigation-drawer android-navigation-drawer

我有一个包含多个项目的菜单抽屉,由于某种原因,即使layout_width与parent相匹配,这些项目也不会占用抽屉的整个宽度。 这是drawer_menu.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <item
        android:id="@+id/drawer_user_current"
        android:title=""
        app:actionLayout="@layout/nav_drawer_current_user_profile" />

</menu>

这是nav_drawer_current_user_profile.xml

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <ImageView
        android:id="@+id/img_chat_room_icon"
        android:layout_width="@dimen/size_large"
        android:layout_height="@dimen/size_large"
        android:src="@drawable/ic_person_avatar_blue_24dp" />

    <TextView
        android:id="@+id/txt_user_profile_nav_drawer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ellipsize="end"
        android:maxLines="1"
        android:text="Current user"
        android:textColor="@color/light_blue"
        android:textSize="@dimen/nav_drawer_font_size" />

</LinearLayout>

抽屉本身位于此文件base_layout.xml

<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"
tools:openDrawer="start">

<!-- The main content view -->
<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

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

这就是菜单的呈现方式

enter image description here

如何让物品在右边,并取出抽屉的所有宽度?

2 个答案:

答案 0 :(得分:1)

尝试

android:title="@null" 

在菜单项中

答案 1 :(得分:0)

double[] oneOfTheArrays = twoDArray[i];
double a = oneOfTheArray[0];
相关问题