问题
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.

xml:
<CheckBoxPreference
android:key="keypref"
android:summary="Summary text does wrap around the borders"
android:title="The title of this preference is" >
</CheckBoxPreference>
回答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 ;)
回答2:
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>
来源:https://stackoverflow.com/questions/10349784/how-to-wrap-preference-title