TextViewTest
来源:互联网 发布:小米usb共享网络win10 编辑:程序博客网 时间:2024/06/11 23:21
TextView直接继承了view,他还是EditText、Button两个UI组件的父类。
实例:不同颜色、字体、带链接的文本。
如下界面布局文件。
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="com.example.l2112.textviewtest.MainActivity" tools:showIn="@layout/activity_main" android:orientation="vertical"> <!-- 设置字号为20pt,在文本框结尾处绘制图片 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="我爱Java!" android:textSize="20pt" android:drawableEnd="@drawable/ok" android:drawableRight="@drawable/ok"/> <!-- 设置中间省略,所有字母大写 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" android:text="我爱Java我爱Java我爱Java我爱Java我爱Java我爱Java我爱Java我爱Java我爱Java" android:ellipsize="middle" android:textAllCaps="true"/> <!--对邮件、电话增加链接--> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" android:text="邮件是kongyeeku@163.com,电话是02088888888" android:autoLink="email|phone"/> <!--设置文字颜色、大小,并使用阴影--> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="测试文字" android:shadowColor="#00f" android:shadowDx="10.0" android:shadowDy="8.0" android:shadowRadius="3.0" android:textColor="#f00" android:textSize="18pt"/> <!--测试密码框--> <TextView android:id="@+id/passwd" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/hello" android:password="true"/> <CheckedTextView android:layout_width="match_parent" android:layout_height="wrap_content" android:checkMark="@drawable/ok" android:text="可勾选的文本"/></LinearLayout>另在string.xml中需要定义hello资源。
0 0
- TextViewTest
- vector resize reserve区别
- 拓展控件 - 拓展的TextView
- POJ 2151 概率dp
- ajax $.post()和$.get()的区别
- EditText——右边图片drawableRight的点击事件
- TextViewTest
- 太原UI设计师郭文军讲网页设计及web前端网页宽度要求?
- ViewPager源码不完全解读
- 【SPOJ-KING】King【2-SAT】
- <LeetCode OJ> 77. Combinations
- android.os.NetworkOnMainThreadException
- 【iOS】一个方法读取图片中的二维码信息
- vim中注释多行和删除多行注释
- 欢迎使用CSDN-markdown编辑器