Can't remove navigation drawer item padding - Android

时间:2016-08-31 18:35:25

标签: android android-layout navigation-drawer

I am developing an application in which I need to have navigation drawer with some items. The problem is that I am unable to reduce padding among the items in navigation drawer. I have searched a lot but nothing worked.

Style.xml

<style name="NavDrawerTextStyle" parent="Base.TextAppearance.AppCompat">
        <item name="android:layout_marginTop">0dp</item>
        <item name="android:textSize">12sp</item>
        <item name="android:textStyle">bold</item>
        <item name="android:layout_marginLeft">2dp</item>
        <item name="android:paddingRight">0dip</item>
        <item name="android:paddingStart">10dip</item>
    </style>

I also have tried android:paddingTop but no expected result.

menu.xml

<group android:checkableBehavior="single">
    <item
        android:icon="@mipmap/icon_pak"
        android:id="@+id/idNavPak"
        android:title="Pakistan" />

    <item
        android:icon="@mipmap/icon_world"
        android:id="@+id/idNavWorld"
        android:title="World" />
    <item
        android:icon="@mipmap/icon_business"
        android:id="@+id/idNavBusiness"
        android:title="Business" />
    <item
        android:id="@+id/idNavSports"
        android:icon="@mipmap/icon_sports"
        android:title="Sports" />
    <item
        android:id="@+id/idNavErtainmentnent"
        android:icon="@mipmap/icon_entermnt"
        android:title="Entertainment" />
    <item
        android:id="@+id/idNavHealth"
        android:icon="@mipmap/icon_health"
        android:title="Health" />
    <item
        android:id="@+id/idNavTv"
        android:icon="@mipmap/live_icon"
        android:title="Live TV"/>
    <item
        android:id="@+id/idNavDost"
        android:icon="@mipmap/icon_dost"
        android:title="Dost 32" />
    <item
        android:id="@+id/idNavCareers"
        android:icon="@mipmap/icon_career"
        android:title="Careers" />
    <item
        android:id="@+id/idNavContactUs"
        android:icon="@mipmap/icon_contact_us"
        android:title="Contact Us" />
   <!--<item
        android:id="@+id/IdNavSettings"
        android:icon="@mipmap/icon_setting"
        android:title="Settings" />-->
</group>

3 个答案:

答案 0 :(得分:0)

Try the solution proposed by gaurav4sarma!

If you still got the same problem, use a custom layout for your navigation drawer items by refering to this link Android Custom Navigation Drawer.

Now, you can manage the space and the padding between different subviews!

Hope this helps :)

答案 1 :(得分:0)

答案 2 :(得分:0)

尝试在导航视图中添加app:itemIconPadding="@dimen/margin_16dp"