Chinaunix首页 | 论坛 | 博客
  • 博客访问: 98069
  • 博文数量: 30
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 91
  • 用 户 组: 普通用户
  • 注册时间: 2015-07-24 19:49
文章分类

全部博文(30)

文章存档

2017年(11)

2016年(1)

2015年(18)

我的朋友

分类: 系统运维

2015-11-03 08:46:24

原文地址:TextView 作者:hello_fish

android.widget.TextVied是view类的直接子类

main.xml


    xmlns:android="
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

            android:id="@+id/mytext1"      定义组件ID

        android:layout_width="fill_parent"  组件宽度为屏幕宽度      
        android:layout_height="wrap_content" 组件高度为文字高度
        android:textColor="#FFFF00"  设置文字颜色为黄色
       android:textSize="12px"  设置文字大小为12像素
        android:text="北京" />   设置显示文字

       android:id="@+id/mytext2" 
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:layout_margin="30px" 表示距离上下有30个像素
       android:text="北京" />

        android:id="@+id/mytext3" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10px"距离上面有10个像素
        android:text="ebaixiao"
        android:maxLength="3" />最多只显示3个文字,显示eba

        android:id="@+id/mytext4" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
           android:background="@drawable/fish"
        android:textColor="#000000"
        android:textStyle="bold"
        android:layout_marginTop="10px"
        android:text="在背景上的文字信息" />

       android:id="@+id/msg" 
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
         android:autoLink="all" 里面的链接内容自动的变为地址链接
       android:textColor="#FFFF00"
       android:textSize="45px"
       android:text=" />

所有组件均在R.java中自动生成

 

建立样式表:

在values下建立styles.xml

styles.xml



   

如果要引用样式,需要用style属性


    xmlns:android="
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

            android:id="@+id/msg" 组件ID

        style="@style/msg_style" 定义组件显示的样式风格


        android:text=" />

通过此种方式的显示更加方便与系统的维护操作

阅读(1069) | 评论(0) | 转发(0) |
0

上一篇:View组件

下一篇:Button

给主人留下些什么吧!~~