ListPreference font size

和自甴很熟 提交于 2019-12-11 10:28:43

问题


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

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