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

android widget之TextView

2011-09-25 19:30 232 查看
Android中的TextView 其实相当于很多语言中Label (比如Java Swing 的JLabel),主要是用于显示一个字符串。 比如:



<TextView android:id="@+id/lable1"
android:text="This is a Label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#cc0000"
android:textColor="#ffffff"
android:textSize="16sp"
android:padding="10dip"/>

其中 android:background 设置TextView的背景颜色,

android:textColor 设置TextView的文字颜色。
android:textSize 设置TextView的字体大小。



效果如下:




如果要动态设置TextView的字符串,可以通过程序实现:



TextView tv = (TextView)findViewById(R.id.lable1);
tv.setText("setText ");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐