简单学习Android TextView

 更新时间:2017年09月09日 16:00:10   作者:长彬  
这篇文章主要和大家一起简单学习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评分控件RatingBar使用实例解析

    Android评分控件RatingBar使用实例解析

    这篇文章主要为大家详细介绍了Android评分控件RatingBar使用实例,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2016-10-10
  • Android开发之针对联系人的封装

    Android开发之针对联系人的封装

    本文给大家分享的是如何在Android开发中封装联系人模块以及封装后的使用及总结,最后奉上代码,有需要的小伙伴可以参考下。
    2016-02-02
  • Android中Snackbar的使用方法及小技巧

    Android中Snackbar的使用方法及小技巧

    这篇文章主要给大家介绍了关于Android中Snackbar的使用方法及小技巧的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面来一起学习学习吧。
    2018-03-03
  • Android开发实战之漂亮的ViewPager引导页

    Android开发实战之漂亮的ViewPager引导页

    这篇文章主要介绍了Android开发实战中漂亮ViewPager引导页的制作过程,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2016-08-08
  • Android Activity与Fragment之间的跳转实例详解

    Android Activity与Fragment之间的跳转实例详解

    这篇文章主要介绍了Android Activity与Fragment之间的跳转实例详解的相关资料,需要的朋友可以参考下
    2017-02-02
  • Android编程实现图标拖动效果的方法

    Android编程实现图标拖动效果的方法

    这篇文章主要介绍了Android编程实现图标拖动效果的方法,涉及Android事件响应及图标变换的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下
    2015-11-11
  • Android实现简易计算器(可以实现连续计算)

    Android实现简易计算器(可以实现连续计算)

    这篇文章主要为大家详细介绍了Android实现简易计算器,可以实现连续计算,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2020-03-03
  • Android编程之监听器的实现方法

    Android编程之监听器的实现方法

    这篇文章主要介绍了Android编程之监听器的实现方法,以实例形式较为详细的分析了Android监听器的创建、注册及相关使用技巧,需要的朋友可以参考下
    2015-11-11
  • Android创建与解析XML(二)——详解Dom方式

    Android创建与解析XML(二)——详解Dom方式

    本篇文章主要介绍了Android创建与解析XML(二)——详解Dom方式 ,这里整理了详细的代码,有需要的小伙伴可以参考下。
    2016-11-11
  • Android支付宝支付开发实例

    Android支付宝支付开发实例

    这篇文章主要为大家详细介绍了Android支付宝支付开发实例的相关资料,感兴趣的小伙伴们可以参考一下
    2016-04-04

最新评论