2013-01-11 3 views
6

私は現在、私のMenuItemのためのカスタムレイアウトを使用しています:MenuItemのカスタムレイアウトに使用するパディング、マージン、およびサイズは?

enter image description here

コードは基本的なものです:

<?xml version="1.0" encoding="utf-8"?> 
<menu xmlns:android="http://schemas.android.com/apk/res/android" > 

    <item 
     android:id="@+id/menu_custom" 
     android:actionLayout="@layout/menu_layout" 
     android:showAsAction="always"/> 

</menu> 

ピクセルのアイコンサイズはAndroidの設計およびガイドラインに記載されているが、私はこのアイコンに使用するマージン、パディング、幅、高さについてはわからないので、すべてのデバイスで正当なものに見えます。

私の現在のレイアウト:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/searchProgressWrapper" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" > 


    <ImageButton 
     android:id="@+id/ivfolder" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_gravity="center" 
     android:scaleType="fitCenter" 
     android:background="@drawable/abs__item_background_holo_dark" 
     android:src="@drawable/ic_menu_archive" /> 


</RelativeLayout> 

大きな問題、あなたが見ることができるように、アイコンの幅は完全に間違っていると他のMenuItemには全く似ていないということです。 8dipでなければなりません

答えて

14

android:minWidth56dipandroid:paddingBottomandroid:paddingTopでなければなりません。 <sdk>/platforms/android-17/data/res/values/dimens.xmlで発見:

<!-- Minimum width for an action button in the menu area of an action bar --> 
<dimen name="action_button_min_width">56dip</dimen> 

<!-- Vertical padding around action bar icons. --> 
<dimen name="action_bar_icon_vertical_padding">8dip</dimen> 
+0

もう一度、ありがとうございます;-)私は受け入れる前に待つのに8分かかります。 –

+0

;-) –

+0

Houps ....固定! –

0
View view = mToolbar.getMenu().findItem(R.id.spinner).getActionView(); 

view.setPadding(0,0,0,0); 

これは私のために働きました。

関連する問題