当前位置:操作系统 > 安卓/Android >>

android widget之TextView

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 ");

 

作者“算法 java swing”
 

补充:移动开发 , Android ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,