简单学习Android TextView
本文为大家分享了TextView的简单学习资料,供大家参考,具体内容如下
XML的几个特殊属性
android:autoLink 用于指定是否将文本转换成可点击的超链接形式,它的属性值有none,web,email,phone,map或all
android:drawBottom 用于将图片添加到文本的低端 同理还有上,左,右
android:hint 当文本为空时,默认显示的是什么
android:Grivaity 文本的对齐方式
android:inputType 显示的文本类型
Mainactivity.XML代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
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"
android:orientation="vertical"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="666"
/>
<TextView
android:id="@+id/textview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="测试是否为单行模式"
/>
<TextView
android:id="@+id/textview3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="http://www.baidu.com"
android:autoLink="web"
/>
</LinearLayout>
mainACtivity.java
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
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"
android:orientation="vertical"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="666"
/>
<TextView
android:id="@+id/textview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="测试是否为单行模式"
/>
<TextView
android:id="@+id/textview3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="http://www.baidu.com"
android:autoLink="web"
/>
</LinearLayout>
运行结果

上述中的链接如果把apk导入到手机上真的能连接到百度,是不是很神奇….
- android TextView设置中文字体加粗实现方法
- Android TextView设置背景色与边框的方法详解
- android实现上下滚动的TextView
- android TextView多行文本(超过3行)使用ellipsize属性无效问题的解决方法
- android TextView不用ScrollViewe也可以滚动的方法
- Android编程开发之TextView文字显示和修改方法(附TextView属性介绍)
- Android控件系列之TextView使用介绍
- Android TextView字体颜色设置方法小结
- android TextView加下划线的方法
- Android实现TextView中文字链接的4种方式介绍及代码
相关文章
android自定义ListView实现底部View自动隐藏和消失的功能
本篇文章主要介绍了android自定义ListView实现底部View自动隐藏和消失的功能 ,具有一定的参考价值,感兴趣的小伙伴们可以参考一下。2017-03-03
Android中将Bitmap对象以PNG格式保存在内部存储中的方法
在Android中进行图像处理的任务时,有时我们希望将处理后的结果以图像文件的格式保存在内部存储空间中,本文以此为目的,介绍将Bitmap对象的数据以PNG格式保存下来的方法2017-08-08
Android UI控件之ImageSwitcher实现图片切换效果
这篇文章主要为大家详细介绍了Android UI控件之ImageSwitcher实现图片切换效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2017-12-12
Android开发中DatePicker日期与时间控件实例代码
本文通过实例代码给大家介绍了Android开发中DatePicker日期与时间控件,代码简单易懂,非常不错,具有参考借鉴价值,需要的朋友可以参考下2017-08-08
Android开发获取传感器数据的方法示例【加速度传感器,磁场传感器,光线传感器,方向传感器】
这篇文章主要介绍了Android开发获取传感器数据的方法,结合实例形式分析了Android获取加速度传感器、磁场传感器、光线传感器及方向传感器数据的相关操作技巧,需要的朋友可以参考下2017-11-11
Android中butterknife的使用与自动化查找组件插件详解
这篇文章主要给大家介绍了关于Android中butterknife的使用与自动化查找组件插件的相关资料,文中通过示例代码介绍的非常详细,对各位Android开发者们具有一定的参考学习价值,需要的朋友们下面来一起学习学习吧2019-10-10


最新评论