列表preference字号 [英] ListPreference font size

查看:169
本文介绍了列表preference字号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用列表preference让用户从列表中选择一个位置。结果
一些条目被切断过长的字符串BCS。结果
我在寻找最简单的方式来解决这个问题。一个变体是只使用一个较小的字体大小。结果
在情况下,它没有太多的开销,我会另外分裂成显示在不同的行2字符串文本。

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.

推荐答案

扩展列表preference并覆盖onCreateView()是这样的:

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

这篇关于列表preference字号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆