Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
557 views
in Technique[技术] by (71.8m points)

android - Reduce Menu items width,height and textview size

I had done a menu overflow items.I need to reduce menu items width,height and textview size.

I referred this post.But it is not working for me.I am posted the code and screenshot related to that:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    >

    <item
        android:id="@+id/add"
        android:icon="@drawable/down"
        android:title="Read"
        android:showAsAction="never"
        />
    <item
        android:id="@+id/add2"
        android:icon="@drawable/down"
        android:title="write"
        android:showAsAction="never"
        />

    <item
        android:id="@+id/add3"
        android:icon="@drawable/down"
        android:title="bold"
        android:showAsAction="never"
        />
</menu>

Menu Item Screenshot:

enter image description here

styles.xml:

   <style name="AppBaseTheme" parent="android:Theme.Light">

    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <item name="android:actionOverflowButtonStyle">@style/MyActionButtonOverflow</item>
    </style>

    <style name="MyActionButtonOverflow" parent="android:style/Widget.Holo.ActionButton.Overflow">
        <item name="android:src">@drawable/down</item>

    </style>

My only problem is,I need to reduce the width,height and textview Size in menu items.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I can reduce the height and text size of the menu items with the help of below codes:

res/values/styles.xml:

    <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
 
        <item name="android:dropDownListViewStyle">@style/PopupMenuListView</item>
        <item name="android:actionBarWidgetTheme">@style/PopupMenuTextView</item>
        <item name="android:popupMenuStyle">@style/PopupMenu</item>
 
        <!-- Change Overflow Menu ListView Item Height & Property -->
        <item name="android:listPreferredItemHeightSmall">10dp</item>
        <item name="android:listPreferredItemPaddingLeft">5dp</item>
        <item name="android:listPreferredItemPaddingRight">5dp</item>
    </style>
 
    <!-- Change Overflow Menu ListView Divider Property -->
    <style name="PopupMenuListView" parent="@android:style/Widget.Holo.ListView.DropDown">
        <item name="android:divider">#FF0000</item>
        <item name="android:dividerHeight">2dp</item>
    </style>
 
    <!-- Change Overflow Menu ListView Text Size and Text Size -->
     <style name="PopupMenuTextView" parent="@style/android:Theme.Holo.Light">
        <item name="android:textColor">#00FF00</item>
        <item name="android:textSize">5sp</item>
    </style>
 
     <!-- Change Overflow Menu Background -->
     <style name="PopupMenu" parent="android:Widget.Holo.Light.ListPopupWindow">
        <item name="android:popupBackground">#888888</item>
    </style>
 
</resources>

Add the above codes in styles.xml(v11) and styles.xml(v14).

For More Detail:

Refer Action Bar Overflow Menu Customization


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...