TextView的简单使用

我们在第一个Android应用,hello OurAndroid中,其实已经用到了Textview这个控件了,我们在Android开发中一般会使用TextView来显示文本内容,这篇我将介绍一个使用布局文件控制的TextView。

动作一:

创建TextViewTest工程;

动作二:

修改res/layout/main.xml文件,我在布局文件里面添加了一个TextView控件,主要修改内容见横线部分;

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout  
  3.     xmlns:android="http://schemas.android.com/apk/res/android"  
  4.     android:orientation="vertical"  
  5.     android:layout_width="fill_parent"  
  6.     android:layout_height="fill_parent">  
  7.     <TextView  
  8.         android:layout_width="fill_parent"  
  9.         android:layout_height="wrap_content"  
  10.         android:text="@string/hello" />  
  11.     <TextView  
  12.         android:id="@+id/myTextView"  
  13.         android:layout_width="fill_parent"  
  14.         android:layout_height="wrap_content"  
  15.         android:text="这是TextView" />  
  16. </LinearLayout> 

动作三:

修改TextViewTestActivity.java文件,文件内容如下:

动作四:

运行程序工程,效果如下:

运行TextViewTest工程截图

源码:TextViewTest

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值