小编JOH*_*GAN的帖子

Android NaviagtionDrawer Item 文本对齐

我像这样创建了 NavigationView 我的导航视图截图

,这是我的 xml 代码

<RelativeLayout 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/top_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".Dashbored">

<include
android:id="@+id/tool_bar"
layout="@layout/tool_bar">
</include>

<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/tool_bar"
android:elevation="7dp"
android:fitsSystemWindows="true"
tools:openDrawer="end">


<LinearLayout
android:id="@+id/linear_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">


<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent">

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

</FrameLayout>


</LinearLayout>

<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="#0284fe"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header"
app:itemBackground="@drawable/drawer_backg"
app:itemIconTint="@color/drawer_item"
app:itemTextAppearance="@style/NavDrawerTextStyle"
app:itemTextColor="@color/windowBackground"
app:menu="@menu/main_drawer" />


</android.support.v4.widget.DrawerLayout>
</RelativeLayout>   
Run Code Online (Sandbox Code Playgroud)

我想像这样设置项目文本对齐中心

我需要这样的输出

这是我的菜单 xml

<?xml version="1.0" encoding="utf-8"?><menu 
xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_inspec_rpt"
android:title="INSPECTION REPORTS"
/>
<item
android:id="@+id/nav_action"
android:title="ACTION ITEMS"
/>
<item
android:id="@+id/nav_appoint"
android:title="APPOINTMENTS" />
<item …
Run Code Online (Sandbox Code Playgroud)

android android-xml android-studio navigation-drawer

1
推荐指数
1
解决办法
4731
查看次数

Android导航视图自定义宽度

有没有办法给Android导航视图自定义宽度,我正在使用Android工作室.我通过谷歌搜索尝试了不同的方式,但没有运气,请帮助我.

在处理不同屏幕尺寸时,最佳做法是提供自定义宽度吗?

这是我的xml代码

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/top_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".Dashbored">

<include
    android:id="@+id/tool_bar"
    layout="@layout/tool_bar">

</include>


<android.support.v4.widget.DrawerLayout
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/tool_bar"
    android:elevation="7dp"
    android:fitsSystemWindows="true"
    tools:openDrawer="end">


    <LinearLayout
        android:id="@+id/linear_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">


        <FrameLayout
            android:id="@+id/frame_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

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

        </FrameLayout>


    </LinearLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="end"
        android:background="#0284fe"
        android:fitsSystemWindows="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <include
                android:id="@+id/navheader"
                layout="@layout/nav_header" />

            <ListView
                android:id="@+id/lst_menu_items"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:divider="@null"
                android:dividerHeight="0dp"

                />
        </LinearLayout>

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


</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

谢谢

xml android navigation-drawer

0
推荐指数
1
解决办法
3932
查看次数