您的位置:首页 > 移动开发 > Android开发

android竖排显示TextView

2016-06-24 11:12 429 查看
其实可以使用换行符实现,如果不嫌麻烦,又使用的少的情况下,下面是自定义一个TextView实现

public class TextViewVertical extends TextView {

public TextViewVertical(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}

public TextViewVertical(Context context) {
super(context);
// TODO Auto-generated constructor stub
}

@Override
public void setText(CharSequence text, BufferType type) {
// TODO Auto-generated method stub
if ("".equals(text) || text == null || text.length() == 0) {
return;
}
int m = text.length();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < m; i++) {
CharSequence index = text.toString().subSequence(i, i + 1);
sb.append(index + "\n");
}
super.setText(sb, type);
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: