I’m writing a preference screen in in xml for my Android application. My issue is that some of the titles of the preferences are too long and will not wrap the page. Consider my example:
<CheckBoxPreference
android:title="Language Detection (BETA)"
android:defaultValue="false"
android:summary="Automatically decide which language to use"
android:key="lan_det_pref"
android:textSize="15px"
android:lines="4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
Maybe I’m missing something but I have tried using number of other properties with no positive results. I have tried android:singleLine, android:lines, etc., and none of these seem to effect the title of the preference. Also is there a way to scale down the size of a CheckBox title?
Any help would be greatly appreciated.
Thanks 🙂
A CheckBoxPreference is not derived from View, so the usual view attributes don’t apply.
Instead, a CheckBoxPreference is bound to a view, which has a predefined layout.
You can derive a class from CheckBoxPreference and override onBindView. In your class’ onBindView, find the CheckBox view and adjust its view attributes to your liking.
Then in your layout, reference your class instead of CheckBoxPreference: