Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where is the attribute android:titleCondensed applicable in menu

Tags:

android

Can anybody please explain me about this? I couldn't find sufficient information in developer documentation. Is it also applicable when item is shown as action and long clicked on icon shows a toast containing title.

like image 340
PK Gupta Avatar asked Aug 09 '14 22:08

PK Gupta


2 Answers

In short: it shows up when space is nice to be kept.

I took pictures on Galaxy S4 4.4.2.

The first picture is a landscape, having only three selection related icons, you can see that the condensed title is used there: enter image description here however if I don't supply the the titleCondensed it uses title and it clearly fits: enter image description here

The full title is used at any other places where space is not an issue, like the "tooltip" (long press on an action bar icon, internally called cheat sheet) or the overflow menu: enter image description here

... and here's part of code I used (with appcompat-v7):

<menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto">
    <!-- Possibly more items like "Edit Item" and "Delete Item" below -->
    <item android:id="@+id/action_select_all"
        android:icon="@drawable/ic_action_select_all"
        android:title="Select All"
        android:titleCondensed="All"
        app:showAsAction="ifRoom|withText" />
    <!-- Same for Select None <-> None -->
    <!-- Same for Invert Selection <-> Invert -->
</menu>

All of the above is empirical observation, and hence probably incomplete, but I was curious, so here are the Android code points implementing the below:
Note the internal package and these are from the framework not the support library!

  • MenuItemImpl.getTitleForItemView returns the title based on prefersCondensedTitle, which has three implementations:

    1. Action Bar icon and text: ActionMenuItemView: true
    2. Action Bar overflow probably: ListMenuItemView: false
    3. Old style Options Menu: IconMenuItemView: true
like image 84
TWiStErRob Avatar answered Nov 09 '22 06:11

TWiStErRob


http://developer.android.com/guide/topics/resources/menu-resource.html

Simply put, the titleCondensed is the title you would like to show when the title string is too long for the device it's being showed on.

like image 43
Conner Harkness Avatar answered Nov 09 '22 05:11

Conner Harkness