Android TextVIew 文字横向竖排
2017-07-02 13:32
274 查看
public class VerticalTextView extends LinearLayout{
public VerticalTextView(Context context, AttributeSet attrs) {
super(context, attrs);
setOrientation(VERTICAL);
this.context=context;
}
private String text;
private Context context;
private int color;
private int size;
public VerticalTextView(Context context) {
super(context);
setOrientation(VERTICAL);
this.context=context;
}
public void setText(String text)
{
this.text=text;
addText();
}
private void addText()
{
removeAllViews();
if(text!=null)
{
char[] chara=text.toCharArray();
for(int i=0;i<chara.length;i++)
{
// System.out.println("什么情况------"+text);
TextView oneText=new TextView(context);
oneText.setTextColor(color);
oneText.setText(text.substring(i, i+1));
if(size>0)
{
oneText.setTextSize(size);
}
addView(oneText);
}
}
}
public void setTextColor(int color)
{
this.color=color;
}
public void setTextSize(int size)
{
this.size=size;
}
}
public VerticalTextView(Context context, AttributeSet attrs) {
super(context, attrs);
setOrientation(VERTICAL);
this.context=context;
}
private String text;
private Context context;
private int color;
private int size;
public VerticalTextView(Context context) {
super(context);
setOrientation(VERTICAL);
this.context=context;
}
public void setText(String text)
{
this.text=text;
addText();
}
private void addText()
{
removeAllViews();
if(text!=null)
{
char[] chara=text.toCharArray();
for(int i=0;i<chara.length;i++)
{
// System.out.println("什么情况------"+text);
TextView oneText=new TextView(context);
oneText.setTextColor(color);
oneText.setText(text.substring(i, i+1));
if(size>0)
{
oneText.setTextSize(size);
}
addView(oneText);
}
}
}
public void setTextColor(int color)
{
this.color=color;
}
public void setTextSize(int size)
{
this.size=size;
}
}
相关文章推荐
- Android TextView文字横向自动滚动(跑马灯)
- Android:TextView文字横向自动滚动(跑马灯)
- Android TextView文字横向自动滚动(跑马灯)
- Android TextView文字横向自动滚动…
- Android Vertical TextView 文字竖排
- Android TextView文字横向自动滚动(跑马灯)
- Android Vertical TextView 文字竖排
- Android TextView文字横向自动滚动(跑马灯)
- Android TextView文字横向自动滚动(跑马灯)
- Android文字自动横向滚动的TextView(文字长度不够也可以)
- Android TextView文字横向自动滚动(跑马灯)
- Android Vertical TextView 文字竖排
- Android TextView文字横向自动滚动(跑马灯)
- Android TextView 横排文字变竖排的简单方法
- Android TextView文字横向自动滚动(跑马灯)
- Android TextView文字横向自…
- Android TextView文字横向自动滚动(跑马灯)
- Android 更改TextView文字颜色(引用Drawable颜色常数及背景色)
- 解决:android TextView上响应部分文字的事件
- Android之TextView实现文字过长时省略部分或者滚动显示