android笔记---textVIew控件,EditText控件
textView控件
1.xml格式
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textColor="#00FF00"
android:text="kkk"
/>
2.代码
TextView tv=new TextView(this);
tv.setText("你好");
setContentView(tv);
改变文本颜色
TextView tv=(TextView)findViewById(R.id.tv);
tv.setText(Html.fromHtml("欢迎<font color =blue>光临</font>myHOME"));
TextView tv=(TextView)findViewById(R.id.tv);
String str="欢迎大家来到<myHOME>谢谢光临";
SpannableStringBuilder style=new SpannableStringBuilder(str);
style.setSpan(new ForegroundColorSpan(Color.RED),0, 6, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
style.setSpan(new ForegroundColorSpan(Color.GREEN),6, 14, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
style.setSpan(new ForegroundColorSpan(Color.BLUE),14, 18, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
tv.setText(style);
设置超链:
<TextView
android:id="@+id/tv"
android:autoLink="all"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textColor="#00FF00"
android:text="欢迎大家来到《myHOME》谢谢光临。\n我的博客:http://charmlo.iteye.com/\n我的电话:110"
/>
跑马灯效果
<TextView
android:id="@+id/tv"
android:autoLink="all"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textColor="#00FF00"
android:singleLine="true"
android:focusable="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"
android:text="欢迎大家来到《myHOME》谢谢光临。我的博客:http://charmlo.iteye.com/我的电话:110"
/>
EditText控件
1.去掉焦点
<EditText
android:layout_width="0dp"
android:layout_height="0dp"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
2.限制输入字符数
android:maxLength="3"
3.多行文本框
android:singleLine="false"
to be continued