2017-01-25 175 views
0

嘗試更改默認導航抽屜的圖標大小,並在每個項目後添加分隔線,但我不明白該如何操作?這是菜單抽屜觀點:更改默認導航抽屜的圖標大小

<group android:checkableBehavior="single"> 
    <item 
     android:id="@+id/agenda" 
     android:icon="@drawable/agenda" 
     android:title="AGENDA" 
     /> 
    <item 
     android:id="@+id/speakers" 
     android:icon="@drawable/speakers" 
     android:title="SPEAKERS" /> 
    <item 
     android:id="@+id/schedule" 
     android:icon="@drawable/schedule" 
     android:title="SCHEDULE" /> 
    <item 
     android:id="@+id/organiser" 
     android:icon="@drawable/organiser" 
     android:title="ORGANISER" /> 
    <item 
     android:id="@+id/partners" 
     android:icon="@drawable/partner" 
     android:title="PARTNERS" /> 
    <item 
     android:id="@+id/event_info" 
     android:icon="@drawable/eventinfo" 
     android:title="EVENT-INFO" /> 
</group> 

這是dimens.xml

<resources> 
    <!-- Default screen margins, per the Android Design guidelines. --> 
    <dimen name="activity_horizontal_margin">16dp</dimen> 
    <dimen name="activity_vertical_margin">16dp</dimen> 
    <!-- Default screen margins, per the Android Design guidelines. --> 
    <dimen name="nav_header_vertical_spacing">16dp</dimen> 
    <dimen name="nav_header_height">160dp</dimen> 
</resources> 

回答

0

嘗試一下本作分隔

<group android:checkableBehavior="single"> 
<item 
    android:id="@+id/agenda" 
    android:icon="@drawable/agenda" 
    android:title="AGENDA" 
    /> 
</group> 

<group android:checkableBehavior="single"> 
<item 
    android:id="@+id/speakers" 
    android:icon="@drawable/speakers" 
    android:title="SPEAKERS" /> 
</group> 

<group android:checkableBehavior="single"> 
<item 
    android:id="@+id/schedule" 
    android:icon="@drawable/schedule" 
    android:title="SCHEDULE" /> 
</group> 

<group android:checkableBehavior="single"> 
<item 
    android:id="@+id/organiser" 
    android:icon="@drawable/organiser" 
    android:title="ORGANISER" /> 
</group> 

<group android:checkableBehavior="single"> 
<item 
    android:id="@+id/partners" 
    android:icon="@drawable/partner" 
    android:title="PARTNERS" /> 
</group> 

<group android:checkableBehavior="single"> 
<item 
    android:id="@+id/event_info" 
    android:icon="@drawable/eventinfo" 
    android:title="EVENT-INFO" /> 
</group> 

和圖標,圖標必須是24dp的的尺寸

檢查該鏈接圖標大小 https://material.io/guidelines/patterns/navigation-drawer.html#navigation-drawer-specshttps://material.io/guidelines/layout/metrics-keylines.html#metrics-keylines-touch-target-size

+0

圖標尺寸太小,因爲它看起來非常小,尺寸圖標大小沒有指定...所以在哪裏添加圖標大小? –

+0

你不必定義導航抽屜的圖標大小 –

+0

好的,但我添加它們的圖標看起來太小 –

0

您可以通過覆蓋在dimens.xml design_navigation_icon_size屬性改變的抽屜式導航欄圖標的大小。

<dimen name="design_navigation_icon_size" tools:override="true">40dp</dimen> 

要dimens.xml每個項目添加分隔,你應該給每個組項目提供了獨特的ID如下圖所示

<group 
     android:id="@+id/group_item_1" 
     android:checkableBehavior="single"> 
<item 
    android:id="@+id/agenda" 
    android:icon="@drawable/agenda" 
    android:title="AGENDA"/> 
</group> 

<group 
     android:id="@+id/group_item_2" 
     android:checkableBehavior="single"> 
<item 
    android:id="@+id/speakers" 
    android:icon="@drawable/speakers" 
    android:title="SPEAKERS" /> 
</group> 

<group 
     android:id="@+id/group_item_3" 
     android:checkableBehavior="single"> 
<item 
    android:id="@+id/schedule" 
    android:icon="@drawable/schedule" 
    android:title="SCHEDULE" /> 
</group> 

<group 
     android:id="@+id/group_item_4" 
     android:checkableBehavior="single"> 
<item 
    android:id="@+id/organiser" 
    android:icon="@drawable/organiser" 
    android:title="ORGANISER" /> 
</group> 

<group 
     android:id="@+id/group_item_5" 
     android:checkableBehavior="single"> 
<item 
    android:id="@+id/partners" 
    android:icon="@drawable/partner" 
    android:title="PARTNERS" /> 
</group> 

<group 
     android:id="@+id/group_item_6" 
     android:checkableBehavior="single"> 
<item 
    android:id="@+id/event_info" 
    android:icon="@drawable/eventinfo" 
    android:title="EVENT-INFO" /> 
</group> 

而且覆蓋此行,可刪除填充

<dimen name="design_navigation_padding_top_default" tools:override="true">0dp</dimen> 
<dimen name="design_navigation_separator_vertical_padding" tools:override="true">0dp</dimen> 
<dimen name="design_navigation_padding_bottom" tools:override="true">0dp</dimen>