How to wrap preference title?

我是研究僧i 提交于 2019-12-04 20:36:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!