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代码使图片和文字在同 ...
随机推荐
- [蓝桥杯]ALGO-81.算法训练_动态数组使用
从键盘读入n个整数,使用动态数组存储所读入的整数,并计算它们的和与平均值分别输出.要求尽可能使用函数实现程序代码.平均值为小数的只保留其整数部分. 样例输入: 样例输出: 样例输入: 样例输出: 题目 ...
- RTMP与HLS压力测试工具安装与配置
在CentOS 6.5环境中安装依赖软件包,使用git下载最新版本st-load源码包 [root@localhost ~]# yum install git unzip patch gcc gcc- ...
- java设计模式-工厂系列
一.简单工厂 1.背景: 任意定制交通工具的类型和生产过程 代码: Moveable.java package com.cy.dp.factory; public interface Moveable ...
- Python——numpy(python programming)
np.insert(a,第几行/列,数,axis=??) sum,mean,std,var,min,max,argmin,argmax,unique np.random a=np.random.nor ...
- js中事件三阶段
js中事件三阶段 先贴代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset= ...
- SEO之HTML代码优化
原文地址:http://www.admin5.com/article/20081128/117821.shtml 一.文档类型(DOCTYPE) XHTML1.0有三种DOCTYPE: 1.过渡型 ...
- Oracle 官方文档地址
官方文档地址: https://docs.oracle.com/cd/E11882_01/index.htm
- [UE4]机器人射击逻辑行为树
1.寻找敌人 2.如果没有找到,等待2秒,跳转到1 3.如果找到了,走向敌人 4.走向敌人的过程中,如果看见敌人了,则射击 5.如果敌人没有了,则跳转到1
- CVE-2017-12149漏洞利用
CVE-2017-12149 JBOOS AS 6.X 反序列化漏洞利用 这次分析一下 CVE-2017-12149 ,漏洞已经爆出有几天了,今天就把这个漏洞看一下. ...
- Centos 7 下, 安装odoo 10
1. Centos在虚拟机中, 最小化安装, 网络连接选择的是 桥接模式, 安装完成后, 是不能直接上网的, 输入root 和密码, 登录进去, 然后执行: [root@localhost ~]# v ...