Android UI开发中的常用控件TextView
来源:互联网 发布:软件测试精品课程 编辑:程序博客网 时间:2024/05/17 11:58
TextView
TextView可以说是android中最简单的一个控件了, 主要是用来显示界面上的一段文本信息.
<?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/text_huijun" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" /></LinearLayout>
外面的LinearLayout暂且忽略, 在TextView中我们使用了android:id把当前控件定义了一个唯一的标示.
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”是指定了控件的宽度和高度.
在android中所有的空间都具有两个属性, 可选值有3中:
much_parent: 标示让当前控件的大小刚好和父布局大小一样.
fill_parent: 意义和much_parent相同, 建议使用much_parent
wrap_content: 标示让当前空间的大小刚好包含住里面的内容, 由控件的内容决定控件的大小.
android:text: 表示要显示的内容
下面是运行效果图:
当然我们也可以修改文字的对齐方式:
可选的方式有:top, bottom, left, right, center, 当然他们是可以同时使用的,中间用’|’连接. 比如center_vertical|center_horizontal
下面是center居中的效果和写法
android:layout_gravity=”center”
<TextView
android:id="@+id/text_huijun"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Hello World!" />
当然我们也可以更改文字的大小和颜色:
<TextView
android:id="@+id/text_huijun"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="24sp"
android:textColor="#00ff00"
android:text="Hello World!" />
android:textSize=”24sp”用于指定文字的大小
* android:textColor=”#00ff00”*用于指定文字的颜色
重新运行效果图:
- Android UI开发中的常用控件TextView
- Android UI开发中的常用控件Button
- Android UI开发常用控件
- Android UI 控件之TextView
- Android UI控件之TextView
- android UI开发及常用控件
- Android常用UI组件 - TextView
- Android软件开发常用系统控件(一) TextView
- 第四部分:UI开发常用控件(TextView、Button、EditText、ImageView、ProgressBar、AlertDialog、ProgressDialog)
- Android UI 之TextView控件属性列表
- Android UI 控件详解-TextView(文本视图)
- Android UI设计——TextView控件
- Android UI 设计——TextView 控件
- Android UI基础——TextView控件
- Android中的UI控件
- Android控件开发之TextView
- Android控件开发之TextView
- Android入门--UI开发--常用控件(2)
- HDUoj 1789 Doing Homework again ( 贪心 好题
- Leetcode 139. Word Break
- Bzoj 2242: [SDOI2011]计算器(BSGS)
- find 和 mv
- Leet Code OJ 388. Longest Absolute File Path [Difficulty: Medium]
- Android UI开发中的常用控件TextView
- Linux下ARM汇编语法
- jquery DateTable
- 【学术篇】网络流24题--餐巾计划问题
- python install in linux
- Construct the Rectangle
- [LeetCode]53. Maximum Subarray (动态规划)
- FileChannel
- myBatis:事务管理