Android之TextView组件学习
一、基础学习
1.findViewById返回View类,该类是所有View组件的父类。
2.子类比父类拥有更多的属性和方法,不过子类找不到的话去父类找
3.marquee:华盖,跑马灯效果;orientation:方向。
4.setContentView使用布局文件
5.在TextView中如果text是“张朋飞”,而maxLength是2,那么会截取,只显示“张朋”。
二、实例
1.第一个
1: <?xml version="1.0" encoding="utf-8"?>2: <resources>3: <string name="hello">Hello World, MyTextViewDemo!</string>4: <string name="app_name">文本显示组件:TextView</string>5: </resources>6:
1: <?xml version="1.0" encoding="utf-8"?>2: <LinearLayout3: 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: <!-- 注释不能放在组件当中,会报错8: textSize: android 中字头的大小不是按几号字来区分的,因为那是微软的标准,9: 而在android中我们是以像素等基本的物理单位来衡量的。10: layout_margin是控件之间的距离,padding是控件和其中子件的距离11: -->12: <TextView13: android:id="@+id/mytext1"14: android:layout_width="fill_parent"15: android:layout_height="wrap_content"16: android:textColor="#FFFF00"17: android:textSize="12px"18: android:text="北京魔乐科技软件学院(MLDN)" />19: <TextView20: android:id="@+id/mytext2"21: android:layout_width="fill_parent"22: android:layout_height="wrap_content"23: android:layout_margin="30px"24: android:text="网址:www.mldnjava.cn" />25: <TextView26: android:id="@+id/mytext3"27: android:layout_width="fill_parent"28: android:layout_height="wrap_content"29: android:layout_marginTop="100px"30: android:text="李兴华老师"31: android:maxLength="3"/>32: <TextView33: android:id="@+id/mytext4"34: android:layout_width="wrap_content"35: android:layout_height="wrap_content"36: android:background="@drawable/logo"37: android:textColor="#0000FF"38: android:textStyle="bold"39: android:text="这是在背景上的文字信息" />40: </LinearLayout>41:

2.第二个
1: <?xml version="1.0" encoding="utf-8"?>2: <LinearLayout3: 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: <!-- 有人说网址后面必须加空格或者换行,否则地址就包含网址2字8: autoLink 可选值(none/web/email/phone/map/all),9: autoLink 是针对里面输入的内容的格式。当设置成 "web" 格式时,可以识别 "http://" 开头的文本,10: 当用户点击时,可以自动打开浏览器。同理,设置成"phone" "email" 格式时,11: 当遇到 "+860757XXXXXXXX" 电话号码时,用户点击会自动拨打电话,12: 遇到"XXX@csdn.net" E-mail 格式时,用户点击会触发 email 功能。13: -->14: <TextView15: android:id="@+id/msg"16: android:layout_width="fill_parent"17: android:layout_height="wrap_content"18: android:autoLink="all"19: android:textColor="#FFFF00"20: android:textSize="45px"21: android:text="网址:www.mldnjava.cn" />22: </LinearLayout>23:

3.第三个
1: <?xml version="1.0" encoding="utf-8"?>2: <LinearLayout3: 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: <TextView8: android:id="@+id/msg"9: style="@style/msg_style"10: android:text="网址:www.mldnjava.cn" />11: </LinearLayout>12:
1: <?xml version="1.0" encoding="utf-8"?>2: <resources>3: <style name="msg_style">4: <item name="android:textSize">45px</item>5: <item name="android:textColor">#FFFF00</item>6: <item name="android:autoLink">all</item>7: <item name="android:layout_width">fill_parent</item>8: <item name="android:layout_height">wrap_content</item>9: </style>10: </resources>11:
Android之TextView组件学习的更多相关文章
- 我的Android进阶之旅------> Android为TextView组件中显示的文本添加背景色
通过上一篇文章 我的Android进阶之旅------> Android在TextView中显示图片方法 (地址:http://blog.csdn.net/ouyang_peng/article ...
- 我的Android进阶之旅------> Android为TextView组件中显示的文本加入背景色
通过上一篇文章 我的Android进阶之旅------> Android在TextView中显示图片方法 (地址:http://blog.csdn.net/ouyang_peng/article ...
- 我的Android进阶之旅------> Android为TextView组件中显示的文本加入背景色
通过上一篇文章 我的Android进阶之旅------> Android在TextView中显示图片方法 (地址:http://blog.csdn.net/ouyang_peng/article ...
- Android之EditText组件学习
一.基础学习 1.Button是TextView的一个子类,所以按钮本身是一个特殊的文本,属性和TextView相似 2.EditText类似html里的input type="text&q ...
- 12.Android之Tabhost组件学习
TabHost是整个Tab的容器,TabHost的实现有两种方式: 第一种继承TabActivity,从TabActivity中用getTabHost()方法获取TabHost.各个Tab中的内容在布 ...
- Android的四大组件学习
一.Linearlayout : 线性布局 1. android:orientation="vertical" //控件的方向控制,vertical : 垂直布局 , ...
- 我的Android进阶之旅------> Android在TextView中显示图片方法
面试题:请说出Android SDK支持哪些方式显示富文本信息(不同颜色.大小.并包括图像的文本信息).并简要说明实现方法. 答案:Android SDK支持例如以下显示富文本信息的方式. 1.使用T ...
- 我的Android进阶之旅------> Android在TextView中显示图片方法
面试题:请说出Android SDK支持哪些方式显示富文本信息(不同颜色.大小.并包含图像的文本信息),并简要说明实现方法. 答案:Android SDK支持如下显示富文本信息的方式. 1.使用Tex ...
- Android(java)学习笔记139:在TextView组件中利用Html插入文字或图片
首先我们看看代码: 1.activity_main.xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/r ...
随机推荐
- 对ContentProvider中getType方法的一点理解
在上篇博客中我们介绍了自定义ContentProvider,但是遗漏掉了一个方法,那就是getType,自定义ContentProvider一般用不上getType方法,但我们还是一起来探究下这个方法 ...
- JAVA_基础面试题
1.面向对象的特征有哪些方面 1.抽象:抽象就是忽略一个主题中与当前目标无关的那些方面,以便更充分地注意与当前目标有关的方面.抽象并不打算了解全部问题,而只是选择其中的一部分,暂时不用部分细节.抽 ...
- asp.net中Get请求和Post请求
Get和Post请求的区别:Get请求因为传输的数据在URL中,因此不安全,而且多数浏览器有限制其长度,最长为2KB.通过Get请求获取数据的方式:string strName=context.Req ...
- /etc/shadow
这样,用户帐户本身在 /etc/passwd 中定义.Linux 系统包含一个 /etc/passwd 的同伴文件,叫做 /etc/shadow.该文件不像 /etc/passwd,只有对于 root ...
- Ext.Net学习笔记02:Ext.Net用法概览
这两天越来越觉得Ext.Net很强大,如果运用熟练可以极大的提高编程效率.如果你也要学习Ext.Net,推荐你看一下<Ext.Net Web 应用程序开发教程>. Ext.Net与ExtJ ...
- (二)Android 基本控件
第一节:View 视图组件 Andorid 中的View 视图组件,实现类是android.view.View 类,是绝大多数图形显示类的父类,提供了大量的方法和属性.在View 类下,有很多子类,如 ...
- windows2008 x86 安装 32位oracle
1.windows 2008 升级到sp2补丁 下载地址 : http://www.microsoft.com/zh-cn/download/confirmation.aspx?id=15278 2. ...
- CSS常见选择器
一.元素选择器 p,html,h1, h2 1.多个元素一起设置同一种风格, 则用逗号“,”隔开(选择器分组) 2.通配符选择, *{Color:red} 表示文档中所有元素都为红色 二.类选择器 ...
- UIImagePickerController显示中文界面
iOS开发中,我们经常遇到获取拍照.相册中图片的功能,就必然少不了UIImagePickerController,但是我们发现当我们使用它的时候,它的页面是英文的,看着很别扭,国人还是比较喜欢看中文界 ...
- Xcode 7 支持http请求info.plist设置
由于iOS9改用更安全的https,为了能够在iOS9中正常使用http发送网络请求,请在"Info.plist"中进行如下配置,否则影响SDK的使用. 1.找到项目中的 Info ...