13

The buttons on the action bar on this tablet, if shown with text, suffer from text warping as in the screenshot below:

enter image description here

I tried many possible settings combinations (ifRoom, always, withText,...). Even attempting to manipulate the actual view of the button get me nowhere (or maybe I didn't persevere enough). Setting the widths of the TextView and the parent LinearLayout had no effect unless they're fixed numbers.

Any ideas?

EDIT:

I neglected to mention that attempting to use an icon along with text only shows the icon. This is using the native action bar. Below is the xml of the action button above:

 <item
    android:id="@+id/itemConfig"
    android:showAsAction="ifRoom|withText"
    android:title="Network Config"
    android:visible="true"/>

Setting the menu item in the following manner:

<item
        android:id="@+id/itemConfig"
        android:icon="@drawable/ic_action_networkconfig"
        android:showAsAction="ifRoom|withText"
        android:title="@string/network_config"
        android:visible="true"/>

causes this

enter image description here

So in essence, the tablet doesn't like text in its action bar. Any clues?

mido
  • 583
  • 1
  • 4
  • 20
  • 3
    show toolbar code, menu xml – Elltz Aug 28 '16 at 21:15
  • 1
    Where is the code ? – Michael B. Aug 31 '16 at 12:11
  • 1
    Post your design code. – Pravin Divraniya Sep 01 '16 at 07:43
  • 1
    Do you use `ActionBarCompat`, or the native `ActionBar` implementation? ([Just in case](http://www.xda-developers.com/the-sorry-state-of-android-fragmentation/).) – Diti Sep 01 '16 at 12:05
  • Sorry for the late response; please find the requested information above – mido Sep 04 '16 at 12:36
  • 4
    I have seen this once with a cheap Chinese phone, somehow they broke the text wrapping algorithm system-wide (I guess it's because they never expected anyone to use the phone in English, so they "optimized" the algorithm for Chinese). I don't think there's really any good solution for this, unfortunately, short of manually rendering your own custom TextView. – Andrew Sun Sep 04 '16 at 12:56
  • That actually makes sense; if I have the time maybe I'll try that approach – mido Sep 04 '16 at 14:14
  • Does it work on other devices? Which version of Android, both code compilation and what is running on this device? – Jon Adams Sep 09 '16 at 15:40
  • What about using custom layout action item to solve the problem? – Gohan Sep 12 '16 at 08:44
  • @JonAdams Yes it works on samsung and lenovo tablets, and even on a sony xperia smartphone. The huawei tablet is the only one that has this behavior among our test devices – mido Sep 21 '16 at 15:25

3 Answers3

2

It looks like your menu code is correct. For reference check my menu item xml:

 <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/itemConfig"
        android:icon="@drawable/icon"
        app:showAsAction="withText|always"
        android:title="@string/network_config"/>
</menu>

Device will show text with icon only if we have space. You can check with landscape mode. Here is the example portarit mode landscape mode

Akash Jain
  • 437
  • 2
  • 13
1

Source: http://developer.android.com/guide/topics/ui/actionbar.html#ActionItems

If your menu item supplies both a title and an icon—with the title and icon attributes—then the action item shows only the icon by default.

If you want to display the text title, add "withText" to the showAsAction attribute.

Note: The "withText" value is a hint to the action bar that the text title should appear. The action bar will show the title when possible, but might not if an icon is available and the action bar is constrained for space.

Yogesh Rathi
  • 6,331
  • 4
  • 51
  • 81
  • The fact that withText is only a hint is important to note of course. The case here is that the OS on Huawei decided that there's no space on a 7 inch tablet! My 5 inch smartphone shows both text and icon when asked! – mido Oct 11 '16 at 10:26
0

Long story short, it couldn't be done :)

mido
  • 583
  • 1
  • 4
  • 20