Android控件之TextView

原帖地址:http://www.cnblogs.com/skywang12345/archive/2013/06/14/3113829.html

Android控件之TextView


1 TextView介绍


TextView是Android的文本显示器,主要用于文本显示。Android的TextView提供了许多属性和方法用于显示参数设置,参考下面表格:



2 TextView示例


建立一个activity,分别3个文本;
第一个文本,采用默认的字体大小和字体颜色置。
第二个文本,字体大小24sp,字体颜色绿色。
第三个文本,字体大小32sp,字体颜色#FF00BBCC。其中FF表示透明度为不透明,00BBCC是颜色值。


应用层代码




 1 package com.skywang.control;
2
3 import android.app.Activity;
4 import android.os.Bundle;
5
6 public class TextViewTest extends Activity {
7 /** Called when the activity is first created. */
8 @Override
9 public void onCreate(Bundle savedInstanceState) {
10 super.onCreate(savedInstanceState);
11 setContentView(R.layout.main);
12 }
13 }


View Code

manifest文件




 1 <?xml version="1.0" encoding="utf-8"?>
2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 package="com.skywang.control"
4 android:versionCode="1"
5 android:versionName="1.0" >
6
7 <uses-sdk android:minSdkVersion="10" />
8
9 <application
10 android:icon="@drawable/ic_launcher"
11 android:label="@string/app_name" >
12 <activity
13 android:name=".TextViewTest"
14 android:label="@string/app_name" >
15 <intent-filter>
16 <action android:name="android.intent.action.MAIN" />
17
18 <category android:name="android.intent.category.LAUNCHER" />
19 </intent-filter>
20 </activity>
21 </application>
22
23 </manifest>


View Code

layout文件




 1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:layout_width="fill_parent"
4 android:layout_height="fill_parent"
5 android:orientation="vertical" >
6
7 <TextView
8 android:layout_width="fill_parent"
9 android:layout_height="wrap_content"
10 android:text="@string/text_01" />
11
12 <TextView
13 android:layout_width="fill_parent"
14 android:layout_height="wrap_content"
15 android:textColor="#00FF00"
16 android:textSize="24sp"
17 android:text="@string/text_02" />
18
19
20 <TextView
21 android:layout_width="fill_parent"
22 android:layout_height="wrap_content"
23 android:textColor="#FF00BBCC"
24 android:textSize="32sp"
25 android:text="@string/text_02" />
26
27 </LinearLayout>


View Code

 


运行效果:如图



 



点击下载:源代码


 

本文链接

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值