Greelings
Greelings

Reputation: 5434

Android : Remove the vertical padding from the popup menu items

I'm trying to remove the vertical padding between each item of a PopupMenu.

PopupMenu popup = new PopupMenu(this, this.findViewById(R.id.popup_button));

I specified the item height, but I did not find the item padding attribute :

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:popupMenuStyle">@style/AppTheme.Popup</item>
    </style>

    <style name="AppTheme.Popup" parent="Widget.AppCompat.PopupMenu.Overflow">
        <item name="android:listPreferredItemHeightSmall">@dimen/content_item_height</item>

        <!-- How can I remove the vertical padding between each item? -->
    </style>

enter image description here

The item height is represented by the red rectangles.

Upvotes: 1

Views: 2285

Answers (1)

Greelings
Greelings

Reputation: 5434

I really don't know why, but doing this :

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:listPreferredItemHeightSmall">@dimen/content_item_height</item>
</style>

instead of :

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:popupMenuStyle">@style/AppTheme.Popup</item>
</style>

<style name="AppTheme.Popup" parent="Widget.AppCompat.PopupMenu.Overflow">
    <item name="android:listPreferredItemHeightSmall">@dimen/content_item_height</item>
</style>

fixed the problem.

Upvotes: 5

Related Questions