简体   繁体   中英

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.

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM