`

TextView基本属性使用

阅读更多



注意:text1 text2 ... text7 text8中的...是表示text3 text 4直到text7,而不是真的...



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#eee"
android:orientation="vertical"
>
	<!-- 
		scrollbar是表示要显示的滚动条;但对于TextView来说滚动条只是一个装饰,只是显示了,没实际功能
		scrollHorizontally表示是否可以水平滚动,false的话就会换行
	-->
	<TextView
	android:layout_width="fill_parent"
	android:layout_height="40sp"
	android:background="#000"
	android:gravity="center"
	android:text="horizontial scrollbar test: text1 text2 text3 ... text7 text8"
	
	android:scrollHorizontally="true"
	android:scrollbars="horizontal"
	/>
	<TextView
	android:layout_width="fill_parent"
	android:layout_height="40sp"
	android:layout_marginTop="1sp"
	android:background="#000"
	android:gravity="center"
	android:text="vertical scrollbar test: text1 text2 text3 ... text7 text8 text9 text0"
	
	android:scrollbars="vertical|horizontal"
	android:textScaleX="1.8"
	/>
	<TextView
	android:layout_width="fill_parent"
	android:layout_height="40sp"
	android:layout_marginTop="1sp"
	android:background="#000"
	android:gravity="center_vertical"
	android:text="ellipsize and singleLine: text1 text2 text3 ... text7 text8 text9 text0"
	
	android:singleLine="true"
	android:ellipsize="middle"
	/>
	<TextView
	android:id="@+id/view"
	android:layout_width="fill_parent"
	android:layout_height="40sp"
	android:layout_marginTop="1sp"
	android:background="#000"
	android:gravity="center_vertical"
	android:text="ellipsize and line: text1 text2 text3 ... text7 text8 text9 text0"
	
	android:minLines="1"
	android:lines="1"
	android:maxLines="1"
	android:ellipsize="middle"
	/>
	<TextView
	android:layout_width="fill_parent"
	android:layout_height="40sp"
	android:layout_marginTop="1sp"
	android:background="#000"
	android:gravity="center_vertical"
	android:text="singleline test: text1 text2 text3 ... text7 text8 text9 text0"
	
	android:singleLine="true"
	/>
	<TextView
	android:layout_width="fill_parent"
	android:layout_height="40sp"
	android:layout_marginTop="1sp"
	android:background="#000"
	android:gravity="center_vertical"
	android:text="length:8 10 13 16 19 22 25"
	
	android:maxLength="20"
	/>
	<!--
	这个是因为设置了layout_width, layout_height,后面的width, height的设置就没起效果
	-->
	<TextView
	android:layout_width="fill_parent"
	android:layout_height="40sp"
	android:layout_marginTop="1sp"
	android:background="#000"
	android:gravity="center_vertical"
	android:text="width and height: text1 text2 text3 ... text7 text8 text9 text0"
	
	android:minWidth="10sp"
	android:width="20sp"
	android:maxWidth="30sp"
	
	android:minHeight="5sp"
	android:height="10sp"
	android:maxHeight="15sp"
	/>
	<TextView
	android:layout_width="fill_parent"
	android:layout_height="40sp"
	android:layout_marginTop="1sp"
	android:background="#000"
	android:gravity="center_vertical"
	android:text="text style test: text1 text2 text3 ... text7 text8 text9 text0"
	
	android:textColor="#f00"
	android:textStyle="bold"
	android:typeface="sans"
	/>
	<TextView
	android:layout_width="fill_parent"
	android:layout_height="40sp"
	android:layout_marginTop="1sp"
	android:background="#000"
	android:gravity="center_vertical"
	android:hint="hit text test: text1 text2 text3 text4"
	
	android:textColorHint="#0f0"
	android:typeface="monospace"
	android:textColorHighlight="#00f"
	/>
	<TextView
	android:layout_width="fill_parent"
	android:layout_height="40sp"
	android:layout_marginTop="1sp"
	android:background="#000"
	android:gravity="center_vertical"
	android:hint="link test: http://www.google.com.hk, google@gmail.com"
	
	android:linksClickable="true"
	android:autoLink="web|email"
	/>
</LinearLayout>


  • 大小: 26 KB
分享到:
评论

相关推荐

    android UI TextView

    基本TextView控件的应用,包括TextView各种属性的设置,特殊的效果的TextView,如带边框的TextView各种实现方法,走马灯,垂直滚动,自动垂直滚动,歌词显示效果,超链接,Html标签在TextView中的应用等。

    Android项目设计与开发:文本框TextView.ppt

    嵌入式Android项目设计与开发 第四章 基本控件编程 ——文本框TextView 引言 Android为编程人员提供了大量的控件,这些控件能实现各类型的功能,正如之前学习过的button和Toast。 本章节我们选取几个较为常用的控件...

    【android编程】 第四讲-Android基本控件

    文章目录Android 基本控件文本框 TextView基本属性其他属性编辑框 EditText普通按钮 Button图片按钮ImageButton单选按钮 RadioButton复选按钮 CheckBox图像视图 ImageView使用私有对象响应按钮点击题目笔记 ...

    SuperTextView-一个功能强大的TextView,可以满足日常大部分布局方式,开发者可已自行组合属性配置出属于自己风格的样式!.zip

    一个功能强大的TextView,可以满足日常大部分布局方式,开发者可已自行组合属性配置出属于自己风格的样式! 基本使用1.添加Gradle依赖 dependencies {  ...  compile '...

    Android_UI_API最全中文文档

    TextView是Android中最基本的文本控件,继承自android.view.View类。它提供了多种方式来显示文本,例如使用android:autoLink属性来设置文本为URL链接、email、电话号码或map时显示为可点击的链接。 其中,TextView...

    Android基础控件(EditView、SeekBar等)的使用方法

    android提供了大量的UI控件,本文将介绍TextView、ImageView、Button、EditView、ProgressBar、SeekBar、ScrollView、WebView的使用方法。在介绍各种控件之前,先简单介绍android UI控件最基本的几种属性: id: id...

    Android代码-SupperShape

    &gt;一个基于iconfont拓展的支持多种功能的轻量级TextView,减少布局嵌套,减少定义shape文件,基本涵盖常规需要多个TextView实现的功能。 功能 不用再写shape.xml文件了!!! 链式调用 涵盖Shape几乎常用的所有属性...

    老罗android视频开发源码和ppt经典

    2.1 android常用布局属性的介绍 2.2 android线性布局的介绍 2.3 android框架布局的使用 2.4 相对布局的使用 2.5 表格布局的介绍 三、Android解析xml文件 3.1 android解析xml文件 3.2 android使用pull解析xml 3.3 ...

    Android studio界面设计与资源PPT

    (1)理解Android屏幕元素的层次结构、View与ViewGroup (2)熟悉Android的布局对象和Android中创建UI界面的...(5)掌握TextView、EditText、Button、DatePicker、TimePicker等常用控件的功能、基本属性以及重要方法

    Android代码-VirtualUETool

    如果你的项目里正在使用 Fresco 的 DraweeView 来呈现图片,那么 UETool 将会提供更多的属性比如图片 URI、默认占位图、圆角大小等等 你可以很轻松的定制任何 view 的属性,比如你想查看一些额外的业务参数 有的时候...

    android部分控件使用代码

    是对一部分基础控件用法的整合。...包括:Button的使用、单选框RadioButton用法、复选框CheckBox用法、UI属性整合、EditText编辑框的基本用法、menu菜单、Intent、TextView以及TextView的稍微高级些的用法。

    Android实例代码

    2.3、基本界面组件:TextView、EditText; Button、ImageButton; 9Patch; RadioButton、CheckBox; ToggleButton;AnalogClock、DigitalClock; ImageView; 2.4、高级界面组件:AutoCompleteTextView; Spinner; ...

    Android项目设计与开发:可编辑文本EditText.ppt

    嵌入式Android项目设计与开发 第四章 基本控件编程 ——可编辑文本EditText EditText EditText和TextView类似,区别在于它允许用户在控件里输入和编辑内容,并可以在程序中对这些内容进行处理。 EditText EditText...

    疯狂Android讲义(第2版)源代码 第6章~第9章

    2.3、基本界面组件:TextView、EditText; Button、ImageButton; 9Patch; RadioButton、CheckBox; ToggleButton;AnalogClock、DigitalClock; ImageView; 2.4、高级界面组件:AutoCompleteTextView; Spinner; ...

    这是一个简单的脉冲倒数视图-Android开发

    库是在kotlin上实现的,但为Java用户提供了便捷的api演示:集成依赖项{实现'com.gusakov:pulse-countdown:1.1.0-rc1'}用法基本上,这是具有自定义属性的textview。 pc_startValue-默认值为10-PulseCountDown的起始...

    疯狂Android讲义源码

     2.3.1 文本框(TextView)与编辑框  (EditText)的功能和用法 60  2.3.2 按钮(Button)与图片按钮(ImageButton)组件的功能和  用法 66  2.3.3 使用9Patch图片作为按钮背景 68  2.3.4 单选按钮...

    android手机开发技术移动应用开发技术实训指导书宣贯.pdf

    本书涵盖了 Android 应用开发的基本概念、组件、布局、事件处理、资源使用等方面的知识。 实训一:简单的 Activity 实训 本实训的目的是掌握 Android 应用开发的过程和资源的使用方法。要求了解 Android 应用开发...

Global site tag (gtag.js) - Google Analytics