Android 学习控件1-TextView
2015-06-14 18:54
477 查看
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!--
定义文本框的Id为mytext1
宽度为整个容器的宽度
高度为文字高度
文字的颜色设置为黄色的RGB码
设置定义文字大小为12像素
-->
<TextView
android:id="@+id/mytext1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFFF00"
android:textSize="12pt"
android:text="这是我写的TextView第一个组件"/>
<!--
定义文本框的Id为mytext2
宽度为整个容器的宽度
高度为文字高度
设置定义文字大小为12像素
距离左边30个像素的距离
-->
<TextView
android:id="@+id/mytext2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12pt"
android:layout_margin="30px"
android:text="这是我写的TextView第二个组件"/>
<!--
定义文本框的Id为mytext3
宽度为整个容器的宽度
高度为文字高度
设置定义文字大小为12像素
设置距离上控件的距离为10个像素
只显示10个长度文字
-->
<TextView
android:id="@+id/mytext3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12pt"
android:layout_marginTop="10px"
android:maxLength="10"
android:text="这是我写的TextView第三个组件"/>
<!--
定义文本框的Id为mytext4
宽度为整个容器的宽度
高度为文字高度
设置定义文字大小为12像素
设置为粗体字体
-->
<TextView
android:id="@+id/mytext4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12pt"
android:textStyle="bold"
android:text="这是我写的TextView第四个组件"/>
</LinearLayout>
效果图:
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!--
定义文本框的Id为mytext1
宽度为整个容器的宽度
高度为文字高度
文字的颜色设置为黄色的RGB码
设置定义文字大小为12像素
-->
<TextView
android:id="@+id/mytext1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFFF00"
android:textSize="12pt"
android:text="这是我写的TextView第一个组件"/>
<!--
定义文本框的Id为mytext2
宽度为整个容器的宽度
高度为文字高度
设置定义文字大小为12像素
距离左边30个像素的距离
-->
<TextView
android:id="@+id/mytext2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12pt"
android:layout_margin="30px"
android:text="这是我写的TextView第二个组件"/>
<!--
定义文本框的Id为mytext3
宽度为整个容器的宽度
高度为文字高度
设置定义文字大小为12像素
设置距离上控件的距离为10个像素
只显示10个长度文字
-->
<TextView
android:id="@+id/mytext3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12pt"
android:layout_marginTop="10px"
android:maxLength="10"
android:text="这是我写的TextView第三个组件"/>
<!--
定义文本框的Id为mytext4
宽度为整个容器的宽度
高度为文字高度
设置定义文字大小为12像素
设置为粗体字体
-->
<TextView
android:id="@+id/mytext4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12pt"
android:textStyle="bold"
android:text="这是我写的TextView第四个组件"/>
</LinearLayout>
效果图:
相关文章推荐
- android之属性动画
- android json解析
- Android之GridView
- Android Studio开发配置NDK环境
- Android中visibility属性VISIBLE、INVISIBLE、GONE的区别
- Android学习记录--ListView取id的疑问
- Android 4.0+ 系统中SystemBars的适配问题
- (转) Android开发性能优化简介
- android adb 读写模式 挂载文件系统
- Android中项目中各个文件夹的含义和用途详解
- Android---56---Android应用调用Web Service/号码归属地查询
- android笔记之ViewFlipper的使用
- Ubuntu环境:Android开发平台搭建
- Android开发之初识Camera图像采集
- Android开发之SurfaceView
- 联想ThinkCenter M4350t型号主机怎样开启Intel Virtualization Technology功能
- android开发论坛
- android开发论坛
- 菜鸟学Android笔记(三十一):Response实现验证码
- Android中 多线程下载原理