8

In this picture, the title of my Preference does not wrap around its parent.

How can I make the title wrap to a new line?

Thanks.

enter image description here

xml:

<CheckBoxPreference
        android:key="keypref"
        android:summary="Summary text does wrap around the borders"
        android:title="The title of this preference is" >
</CheckBoxPreference>
MobileCushion
  • 7,065
  • 7
  • 42
  • 62

2 Answers2

1

You would need to make custom layout which resembles default (android internal) CheckBoxPreference. In that xml text view of title should be with ellipsize set to Marque, repeat limit indefinite and scrollable set to horizontal. Than you can set layout of CheckBoxPreference with:

<CheckBoxPreference
    android:key="key_checkbox_pref"
    android:summary="Summary text does wrap around the borders"
    android:title="The title of this preference."
    android:layout="@layout/custom_checkbox_preferences_layout">

Hope that would work ;)

Wernight
  • 36,122
  • 25
  • 118
  • 131
Ewoks
  • 12,285
  • 8
  • 58
  • 67
-1

Just an update to this. It's a String so you can use \n to create a newline.

<CheckBoxPreference
        android:key="keypref"
        android:summary="Summary text does wrap around the borders"
        android:title="The title of this preference\nis this." >
</CheckBoxPreference>
Aleksander Blomskøld
  • 18,374
  • 9
  • 76
  • 82
Grippie
  • 27
  • 6
  • 4
    This wouldn't work very well on different screen resolutions. – Philio Dec 19 '12 at 10:51
  • this doesn't work if you use `android:title="@string/some_string"` where you put into a strings.xml `the string I want \n to wrap`. Here the `\n` is ignored. – dentex Oct 23 '13 at 14:36
  • 1
    Correction: a `\n` is always ignored. see: http://stackoverflow.com/questions/19616238/how-to-wrap-a-preference-title-really – dentex Oct 27 '13 at 10:18