我创建NavigationView喜欢这个 的Android NaviagtionDrawer项目文本对齐
,这是我的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>
我想设置这样
项目文本对齐中心这是我的菜单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
android:id="@+id/nav_applst"
android:title="MAIN APPOINTMENTS" />
<item
android:id="@+id/nav_logout"
android:title="LOG OUT" />
</group>
我想获得像第二个图像的输出,请帮助我,我试图在style.xml中给这样的样式,但我不知道如何对齐文本,我尝试了不同的方式由谷歌它,但没有运气。 :(
<style name="NavDrawerTextStyle" parent="Base.TextAppearance.AppCompat">
<item name="android:textColor">@color/colorPrimaryDark</item>
<item name="android:textSize">16dp</item>
<item name="android:fontFamily">serif</item>
<item name="android:textStyle">bold</item>
</style>
感谢
最后我找到了一个解决方案,我创建了一个列表视图,而不是菜单,并给文本对齐,其工作正常,谢谢 –
我给了我下面的解决方案,请检查它 –