didi_X8
didi_X8

Reputation: 5068

ListPreference font size

I'm using ListPreference to have the user select a location from a list.
Some of the entries are cut off bcs of too long strings.
I'm looking for the simplest possible way to work around this. One variant would be to just use a smaller font size.
In case it's not too much overhead, I would additionally split the text shown into 2 strings on different lines.

Upvotes: 1

Views: 1538

Answers (1)

gpo
gpo

Reputation: 3689

Extend ListPreference and override onCreateView() like this:

    @Override
protected View onCreateView(ViewGroup parent) {
    View view = super.onCreateView(parent);
    ((TextView) view.findViewById(android.R.id.title)).setSingleLine(false);
    ((TextView) view.findViewById(android.R.id.title)).setMaxLines(2);
    ((TextView) view.findViewById(android.R.id.summary)).setMaxLines(10);
    return view;
}

Upvotes: 3

Related Questions