减少导航抽屉中某些元素的textSize

时间:2017-05-10 15:53:12

标签: android android-layout navigation-drawer

我的NavigationDrawer如下所示:screenshot

我希望减少类别标签之间的空间并减少它们的textSize,以便它们看起来更像列表并占用更少的空间。我怎么能这样做?

activity_main.xml中

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

<group android:checkableBehavior="single">
    <item
        android:id="@+id/newest"
        android:title="@string/nav_newest"/>
    <item
        android:id="@+id/highest_rated"
        android:title="@string/top_rated"/>
    <item
        android:id="@+id/earth_view"
        android:title="@string/Earth_by_satellite"/>
</group>

<item android:title="Categories"
    >
    <menu>
        <group android:checkableBehavior="single">
            <item
                android:id="@+id/Abstract"
                android:title="@string/Abstract"/>

            <item
                android:id="@+id/Animal"
                android:title="@string/Animal"/>
            <item
                android:id="@+id/Anime"
                android:title="@string/Anime"/>
            <item
                android:id="@+id/Comics"
                android:title="@string/Comics"/>
            <item
                android:id="@+id/Earth"
                android:title="@string/Earth"/>
            <item
                android:id="@+id/Fantasy"
                android:title="@string/Fantasy"/>
            <item
                android:id="@+id/Man_Made"
                android:title="@string/Man_Made"/>
            <item
                android:id="@+id/Movie"
                android:title="@string/Movie"/>
            <item
                android:id="@+id/Music"
                android:title="@string/Music"/>
            <item
                android:id="@+id/Photography"
                android:title="@string/Photography"/>
            <item
                android:id="@+id/Sci_Fi"
                android:title="@string/Sci_Fi"/>
            <item
                android:id="@+id/Space"
                android:title="@string/Space"/>
            <item
                android:id="@+id/TV_Show"
                android:title="@string/TV_Show"/>
            <item
                android:id="@+id/Vehicles"
                android:title="@string/Vehicles"/>
            <item
                android:id="@+id/Video_Game"
                android:title="@string/Video_Game"/>
        </group>
    </menu>
</item>

activity_main_drawer.xml

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

main()
{
    double b;int a[2],*c; 
    void myfunction();
    c=(int*)(malloc(1));
    b=10.;
    *c=5;
    a[1]=1;a[2]=2;

    printf("before call %f $d $d %d\n",b,a[1],a[2],*c);
    printf("before call %f $d $d %d\n",b,a[1],a[2],*c);
    myfunction(b,a,c);
    printf("after call %f $d $d %d\n",b,a[1],a[2],*c);
}

void myfunction(x,y,d)
     double x;int y[2],*d;
{
    double z;
    x=2*x;
    y[1]=3*y[1];
    y[2]=3*y[2];
    *d =*d+2;
}

1 个答案:

答案 0 :(得分:0)

在style.xml中自定义文本大小

<style name="NavDrawerTextStyle" parent="Base.TextAppearance.AppCompat">
    <item name="android:textColor">@color/colorPrimaryDark</item>
    <item name="android:textSize">16sp</item>
    <item name="android:textStyle">bold</item>
</style>
您在NavigationView中的

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

<android.support.design.widget.NavigationView
    ...
    app:itemTextAppearance="@style/NavDrawerTextStyle"
     />