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代码使图片和文字在同 ...
随机推荐
- Hadoop 目录分析及存储机制
NameNode元数据目录分析 在第一次部署好Hadoop集群的时候,我们需要在NameNode(NN)节点上格式化磁盘: $HADOOP_HOME/bin/hdfs namenode -format ...
- HanLP用户自定义词典源码分析详解
1. 官方文档及参考链接 l 关于词典问题Issue,首先参考:FAQ l 自定义词典其实是基于规则的分词,它的用法参考这个issue l 如果有些数量词.字母词需要分词,可参考:P2P和C2C这种词 ...
- 通过Hibernate API编写访问数据库的代码
private Configuration config;// 1.声明私有配置对象类private ServiceRegistry serviceRegistry;// 2.声明私有服务注册对象类p ...
- jersey2+freemarker+spring3的集成
由于即将开始的新项目,是一个对外网开放访问权限的web应用.所以,公司技术管理层不允许使用struts以及spring mvc这一套.所以,我们开始转战曾经用作REST API的框架jersey及其周 ...
- java架构师之路--推荐书籍
1.大型网站技术架构:核心原理与案例分析 本书通过梳理大型网站技术发展历程,剖析大型网站技术架构模式,深入讲述大型互联网架构设计的核心原理,并通过一组典型网站技术架构设计案例,为读者呈现一幅包括技术选 ...
- SPI Flash Memory 芯片手册阅读
SPI Flash Memory 芯片手册阅读 信息来源
- ubuntu 17.10.1 安装 virtual box 增强工具
ubuntu 17.10.1 安装 virtual box 增强工具遇到 “ Please install the gcc make perl packages from your distribu ...
- a标签返回上一页,并刷新
<a href="javascript:" onclick="self.location=document.referrer;">返回上一页并刷新& ...
- 关于Dubbo面试问题
一.默认使用的是什么通信框架,还有别的选择吗? 默认也推荐使用netty框架,还有mina. 二.服务调用是阻塞的吗? 默认是阻塞的,可以异步调用,没有返回值的可以这么做. 三.一般使用什么注册中心? ...
- LeetCode——6. ZigZag Conversion
一.题目链接:https://leetcode.com/problems/zigzag-conversion/description/ 二.题目大意: 给定一个字符串和一个数字,将其转换成Zigzag ...