TextView的跑马灯效果(AS开发实战第二章学习笔记)

TextView的跑马灯效果
跑马灯用到的属性与方法说明
singleLine 指定文本是否单行显示
ellipsize 指定文本超出范围后的省略方式
focusable 指定是否获得焦点,跑马灯效果要求设置为true
focusableInTouchMode 指定在触摸时是否获得焦点,跑马灯效果要求设置为true
省略方式的取值说明
start 省略号在开头
middle 省略号在中间
end 省略号在末尾
marquee 跑马灯显示
另外,我还找到了一个marqueeRepeatLimit的属性,其中可以用marquee_forever作为它的值,也可以用数字作为它的值

举个例子:

<TextView

  android:id

  android:layout_width

  android:layout_height

  android:layout_marginTop

  android:singleLine="true"

  android:ellipsize="marquee"

  android:marqueeRepeatLimit="marquee_forever"

  android:focusable="true"

  android:focusableInTouchMode="true"

  android:textColor

  android:textSize

  android:text

  />

原文地址:https://www.cnblogs.com/Briddle-ch/p/8331251.html

时间: 2024-08-02 04:32:07

TextView的跑马灯效果(AS开发实战第二章学习笔记)的相关文章

Android界面(1) 使用TextView实现跑马灯效果

方法一:(只能实现单个TextView的跑马灯效果)在TextView添加以下控件 android:singleLine="true"只能单行,超出的文字显示为"..." android:ellipsize="marquee"省略号没有,但没有跑马灯效果 android:focusable="true" android:focusableInTouchMode="true" 方法二:(可以实现多行TextV

Android 使用TextView实现跑马灯效果

前言 我们在开发中经常会遇到一个小问题.比如下面一个小例子: 这个文字太长,单行中导致无法全部显示出来,这就是今天要实现的功能. 当然,百度中也有很多这种解决方案. 其中有一种,例如: <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:ellipsize=&q

ListView 中的TextView实现跑马灯效果

案例:怎么样在一个ListView中含有TextView的item中实现字母滚动呢.这个在一些特定的场合经常用得到.如下图,当焦点位于某个item的时候其内容就自动滚动显示 要实现这样的效果,废话不多说直接上代码: adapter对应的layout 对应的listView的layout 切记千万不要在TextView中加上android:focusable="true" view plain <LinearLayout android:orientation="vert

安卓TextView的跑马灯效果

跑马灯效果的实现非常简单,可分为两步 1.定义一个View继承TextView,重写isFocused方法 package com.jsako.marquee; import android.content.Context; import android.util.AttributeSet; import android.view.ViewDebug.ExportedProperty; import android.widget.TextView; public class MarqueeTex

android textview 实现跑马灯效果

跑马灯效果最重要的就是四个属性,分别是: android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:singleLine="true" 控件的宽度,不一定是具体的值,可以是math_parent,如果想让textview中的文字滚动的话,那里面内容的长度肯定是要大于控件的长度的,不然滚动还有啥

TextView实现跑马灯效果

使用setSelect(true)来实现, 当然Textview 获得焦点后也会跑马灯 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height=&

android TextView实现跑马灯效果(字体滚动)

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" androi

TextView的跑马灯效果

TextView的gravity属性可以指定文本的对齐方式 跑马灯的实现: 1.singleLine设置为true 2.ellipsize(文本超出后的省略方式,包括start.middle.end.marquee)设置为marquee 3.focusable(是否获得焦点)设置为true 4.focusableInTouchMode(在触摸时候获得焦点)设置为true 原文地址:https://www.cnblogs.com/peter-sun/p/8367405.html

Android使用TextView实现跑马灯效果

一.第一种方式: 通过TextView控件的自身属性实现(但是有缺点就是当多个TextView要实现这种效果的时候,只有第一个才有效果) 实现方法加上下面四个属性: android:singleLine="true" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" <LinearLayout