0

I am developing custom menu item by calling action layout, but when i am taping that action menu that pressing color is not applying total height giving some top and bottom margin.

Below is my code:

<?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> 
Rayani
  • 15
  • 6

1 Answers1

0

Part of the problem is that you're not using an ImageButton.

Combining an image with text is possible with an ImageButton. You can even independently adjust the text and the image inside that ImageButton.

Hopefully, an ImageButton will work inside an action menu, I haven't actually tested that part yet.

Community
  • 1
  • 1
Stephan Branczyk
  • 9,363
  • 2
  • 33
  • 49
  • @Rayani, By the way, if you find an answer most useful to you, marking it accepted is also a good way of saying thank you for it. See: http://meta.stackexchange.com/a/5235/151788 Also, don't discount the use of 9-patch, even if you find it isn't normally used inside of action menus. Using a 9-patch with match_parent and some tweaking inside your existing code would probably have worked as well (without the need of an ImageButton). – Stephan Branczyk Jul 19 '14 at 16:35