Android 抽屉中的物品不占整个宽度
我有一个包含多个项目的菜单抽屉,由于某些原因,这些项目没有占据整个抽屉的宽度,即使布局宽度与父项匹配。 这是drawer_menu.xmlAndroid 抽屉中的物品不占整个宽度,android,navigation-drawer,Android,Navigation Drawer,我有一个包含多个项目的菜单抽屉,由于某些原因,这些项目没有占据整个抽屉的宽度,即使布局宽度与父项匹配。 这是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_c
<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"/>
如何使物品位于右边,并占据抽屉的所有宽度?
<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"
android:layout_marginEnd="-65dp"
android:layout_marginRight="-65dp"
app:menu="@menu/drawer_menu_chat"/>
试试看
在菜单项中@Thunder但我did@Thunder编辑它
android:title="@null"