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代码使图片和文字在同 ...
随机推荐
- Java MyBatis insert数据库数据后返回主键
<selectKey keyProperty="id" resultType="java.lang.Long" order="AFTER&quo ...
- ML: 聚类算法R包-网格聚类
网格聚类算法 optpart::clique optpart::clique CLIQUE(Clustering In QUEst)是一种简单的基于网格的聚类方法,用于发现子空间中基于密度的簇.CLI ...
- FIFO 的控制逻辑---verilog代码
FIFO 的控制逻辑---verilog代码 //fifo的例化 wire fifo_full; wire fifo_empty; : ] fifo_dout; :]rd_data_count; :] ...
- Excel技巧--使用规划求解
当我们需要求在有限预算下可以购买的商品数量时,我们就可以使用“规划求解”功能.如上图,在1000元的预算目标内,我们能购买左图中的各书籍多少本.而这些数量,就可以使用“规划求解”来获取答案. 1.实际 ...
- 错误 Run-time error nnn at xxxx; 错误
出现runtime error临时解决办法,于注册表位置中找到如下键值HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Gdiplus,然后把键DisableTIFFCo ...
- Windows 10 的有趣快捷键
先升级到最新版Windows 10,比如:易升 快捷键 功能 Ctrl+Win+C 感受黑白灰的世界 Win+Shift+S 系统级自由截图快捷键 Win+D Win+Ctrl+D Win+Ctrl+ ...
- 为IE内核的WebBrowser控件内存泄漏所烦恼的可以考虑用Cefsharp代替它!
为IE内核的WebBrowser控件内存泄漏所烦恼的朋友们,可以考虑用Cefsharp代替WebBrowser控件 特意做了一个程序来测试 利用Cefsharp做控件,访问网站.每分钟刷新2次,初始时 ...
- python+selenium自动化软件测试(第3章):unittes
From: https://blog.csdn.net/site008/article/details/77622472 3.1 unittest简介 前言 (python基础比较弱的,建议大家多花点 ...
- STL基础--算法(排序)
STL排序算法 排序算法要求随机访问迭代器 vector, deque, container array, native array 例子 vector<int> vec = {9,1,1 ...
- (转载)通向架构师的道路(第四天)之Tomcat性能调优-让小猫飞奔
转载自:https://blog.csdn.net/lifetragedy/article/details/7708724 参考文章:tomcat以及常用web容器线程池的实现原理https://bl ...