码迷,mamicode.com
首页 > 移动开发 > 详细

Android-TextView文本框Demo

时间:2014-12-28 14:03:23      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

代码

package com.lxt008;

import com.lxt008.R;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.TextView;

public class TextViewActivity extends Activity
{
    /* 声明TextView对象 */
    private TextView textview;
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        /* 获得TextView对象 */
        textview = (TextView)this.findViewById(R.id.textview);
        
        String string = "TextView示例,欢迎使用!";
        
        /* 设置文本的颜色 */
        textview.setTextColor(Color.RED);
        /* 设置字体大小 */
        textview.setTextSize(20);
        /* 设置文字背景 */
        textview.setBackgroundColor(Color.BLUE);
        /* 设置TextView显示的文字 */
        textview.setText(string);
    }
}

 

布局文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <TextView  
    android:id="@+id/textview"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
</LinearLayout>

 

Android-TextView文本框Demo

标签:

原文地址:http://www.cnblogs.com/spadd/p/4189898.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!