问题
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.
回答1:
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;
}
来源:https://stackoverflow.com/questions/6898853/listpreference-font-size