android TextView 例子代码(文字图片、文字省略、文字滚动)
<?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"
tools:context="com.example.prize.mydemo1.Main4Activity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--TextView 放入图片例子-->
<!--android:drawableTop="@drawable/icon1" 在文字上面放入图片-->
<!--android:drawablePadding="20dp" 设置图片与文字之间的间隔-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="努力学习"
android:textColor="#0000ff"
android:textSize="50sp"
android:drawableTop="@drawable/icon1"
android:drawablePadding="20dp"
/>
<!--文字太长显示省略。。。例子-->
<!--android:maxLines="1" 设置TextView行数-->
<!--android:ellipsize="end" 设置文本结尾显示。。。-->
<!--android:layout_marginBottom="5dp" 设置布局间隔-->
<TextView
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="@string/main4Text1"
android:maxLines="1"
android:ellipsize="end"
android:layout_marginBottom="5dp"/>
<!--android:ellipsize="end" 设置文本中间显示省略。。。-->
<TextView
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="@string/main4Text1"
android:maxLines="1"
android:ellipsize="middle"/>
<!--设置有滚动播放效果的文字显示-->
<!--android:singleLine="true" 设置单行-->
<!--android:marqueeRepeatLimit="marquee_forever" 设置滚动次数,这里为永久滚动-->
<!--android:ellipsize="marquee" ellipsize意思省略位置,marquee的意思是滚动模式-->
<!--android:focusable="true" 意思可聚焦,被选中。只有聚焦的文字才会滚动-->
<!--android:focusableInTouchMode="true" 可调焦的触摸模式-->
<!--注意此方法设置文字滚动,一个页面只有一段文字可以被预设聚焦并且滚动-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/main4Text1"
android:layout_marginTop="30dp"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"/>
</LinearLayout>
</LinearLayout>
运行效果:
android TextView 例子代码(文字图片、文字省略、文字滚动)的更多相关文章
- android TextView 例子代码(文字中划线、文字下划线)
XML: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android ...
- Android TextView 显示HTML加图片
TextView显示网络图片,我用android2.3的系统,可以显示图片出来,并且如果图片比较大,应用会卡的现象,肯定是因为使用主线程去获取网络图片造成的,但如果我用android4.0以上的系统运 ...
- Android TextView里直接显示图片的三种方法
方法一:重写TextView的onDraw方法,也挺直观就是不太好控制显示完图片后再显示字体所占空间的位置关系.一般假设字体是在图片上重叠的推荐这样写.时间关系,这个不付源代码了. 方法二:利用Tex ...
- Android:Textview 通过代码设置 Drawable
解决方案 public void setCompoundDrawables (Drawable left, Drawable top, Drawable right, Drawable bottom) ...
- jquery文字上下滚动--单行 批量多行 文字图片上下翻滚 | 多行滚动
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Android TextView 嵌套图片及其点击,TextView 部分文字点击,文字多颜色
1. TextView 中嵌套图片的方法 TextView textView... textView.setText("..."); textView.append(Html.fr ...
- Android TextView中有图片有文字混合排列
Android TextView中有图片有文字混合排列 1.使用html.fromHtml 2.新建ImageGetter 3.使用<img src>标签 demo: 1.设置文字 ((T ...
- android 文字图片合成
引用:http://blog.csdn.net/cq361106306/article/details/8142526 两种方法: 1.直接在图片上写文字 String str = "PIC ...
- 如何利用CSS代码使图片和文字在同一行显示且对齐
对于初学css的新手朋友来说,经常会遇到这样一个问题,当文字和图片出现在同一行或者同一个div里面的时候,在浏览器中运行出来的显示效果往往是在不同的行,那么,我们怎么才能利用CSS代码使图片和文字在同 ...
随机推荐
- Mysql 通信协议抓包分析
mysql在传输层使用的TCP协议.一个TCP payload可能有多个mysql packet.如下图所示. TCP head TCP payload (mysql packet1, mysql p ...
- Django中的URL映射
1.为什么回去urls.py文件中寻找映射呢? 因为在settings.py中配置了ROOT_URLCONF为urls.py: ROOT_URLCONF = 'first_project.urls' ...
- Windows Server 2016 禁止自动更新后重启
管理员运行cmd 输入Sconfig, 选择5,选择m
- influxDB 0.9 C# 读写类
influxDB 0.9 C# 读写类 目前influxdb官网推荐的C#读写类是针对0.8版本的,截至本文写作之前,尚未发现有针对0.9的读写类. 我使用influxdb的是用于保存服务器的运行 ...
- workerman vmstat服务器状态监控服务
转载出自 :http://www.workerman.net/workerman-vmstat workerman vmstat服务器状态监控服务 vmstat 命令可以展现服务器的CPU使用率,内存 ...
- 关于Zookeeper选举机制
zookeeper集群 配置多个实例共同构成一个集群对外提供服务以达到水平扩展的目的,每个服务器上的数据是相同的,每一个服务器均可以对外提供读和写的服务,这点和redis是相同的,即对客户端来讲每个服 ...
- SpringSecurity-ConcurrentSessionFilter的作用
ConcurrentSessionFilter主要有两个功能: (1)每次request时调用SessionRegistry的refreshLastRequest(String)更新session的最 ...
- elasticsearch 口水篇(4)java客户端 - 原生esClient
上一篇(elasticsearch 口水篇(3)java客户端 - Jest)Jest是第三方客户端,基于REST Api进行调用(httpClient),本篇简单介绍下elasticsearch原生 ...
- 有趣的background
前言 background是css的简写形式,可以一次性定义各种背景属性,包括color.image.origin.size,repeat方式等等. background在活动项目中用的还是比较多的, ...
- asp.net 项目目录说明
Bin 目录用来存放编译的结果,bin是二进制binrary的英文缩写,因为最初C编译的程序文件都是二进制文件,它有Debug和Release两个版本, 分别对应的文件夹为bin/Debug和bin/ ...