2014-07-19 36 views
0

我正在通过调用操作布局来开发自定义菜单项,但是当我在录制按下颜色的操作菜单时,未应用总高度给出一些顶部和底部边距。在Android设备上的自定义操作图标

下面是我的代码:问题的

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"  
    android:gravity="center"> 

    <ImageView 
     android:minWidth="56dp" 
     android:id="@+id/voicemailNotificationCounter" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:scaleType="center" 
     android:clickable="true" 
     android:background="@drawable/ab_pressedicon_bgcolor" 
     android:contentDescription="@string/voicemailnotification" 
     android:src="@drawable/ab_voicemail"> 
    </ImageView> 

    <TextView android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/vmNotificationTextCounter" 
     android:text="1" 
     android:visibility="visible" 
     android:layout_alignRight="@+id/voicemailNotificationCounter" 
     android:layout_marginRight="10dp" 
     android:gravity="center" 
     android:textColor="#fff" 
     android:includeFontPadding="false" 
     android:background="@drawable/notification_alertbg" 
     android:textSize="12sp"/> 

</RelativeLayout> 
+0

你的图标是否为九块? –

+0

不,它不是九块图像,它只是普通的操作栏图标。 – Rayani

回答

0

部分原因是,你不使用的ImageButton。

将图像与文字is possible结合成ImageButton。您甚至可以独立调整ImageButton中的文字和图像。

希望ImageButton能够在一个操作菜单中工作,我还没有真正测试过这个零件。

+0

谢谢Stephan ... !!! – Rayani

+0

@Rayani,顺便说一句,如果你找到对你最有用的答案,将其标记为接受也是一种很好的表达方式。请参阅:http://meta.stackexchange.com/a/5235/151788另外,即使您发现它在操作菜单中通常不使用,也不要打折使用9-patch。使用带有match_parent的9补丁,并在现有代码中进行一些调整可能也会有效(不需要ImageButton)。 –