android 实现textView的走马灯

Android实现TextView走马灯效果同时自动更新显示当前时间 在项目开发中,有时候我们需要显示一个走马灯效果,简单的走马灯效果当然容易实现; 在xml文件中给TextView设置以下属性即可; android:focusable=true; android:focuseableInTouchMode=true android:singleLine=true; android:ellipsize=marquee; marqueeRepeatLimi 阅读详情

自定义一个类,继承自TextView

public class AlwaysMarqueeTextView extends TextView {

    public AlwaysMarqueeTextView(Context context,AttributeSet attrs,int defStyle) {
        super(context, attrs, defStyle);
    }

    public AlwaysMarqueeTextView(Context context,AttributeSet attrs) {
        super(context, attrs);
    }

    public AlwaysMarqueeTextView(Context context) {
        super(context);
    }

    @Override
    protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
        if (focused)
            super.onFocusChanged(focused, direction, previouslyFocusedRect);
    }

    @Override
    public void onWindowFocusChanged(boolean hasWindowFocus) {
        if (hasWindowFocus)
            super.onWindowFocusChanged(hasWindowFocus);
    }

    @Override
    public boolean isFocused() {
        return true;
    }

   
}

 

在xml中添加

<com.common.AlwaysMarqueeTextView
            android:id="@+id/frag_home_layout_tvAddress"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_marginRight="1dp"
            android:singleLine="true"
            android:ellipsize="marquee"
            android:marqueeRepeatLimit="marquee_forever"
            android:text="/data/data/data/data/data/data/date/data/data/data"
            android:focusable="true"/>

 

 

Android TextView跑马灯效果 对于很多时候会有显示不全的问题,也就是会以省略号的形式显示,对于可以有焦点的Textview可以很好实现跑马灯效果,但是无焦点的TextView就不好操作,下面我来解决这个问题。 阅读详情

相关推荐

android三种方式实现TextView跑马灯效果

android三种方式实现TextView跑马灯效果

Android三种方式实现TextView跑马灯效果

Android三种方式实现TextView跑马灯效果作为一枚程序猿,能把自己学到的那点可怜的技术记录下来并分享出来真的是件身心愉悦的事情。 以下记录三种方式实现TextView文字滚动的效果。 第一种:原生的android自带的跑马灯效果。直接申明TextView属性。 第二种:改造TextView,自定义View继承的TextView,利用Runnable循环调用onDraw()方法更新视图

琼小资的专栏 1万+

WINCC8.1工业组态软件安装与授权配置指南

SCADA系统作为工业自动化控制的核心平台,通过实时数据采集与监控实现生产流程可视化。WINCC作为西门子旗舰级组态软件,其8.1版本凭借稳定的运行时环境在汽车制造、流程工业等领域广泛应用。本文从工业控制系统软件安装规范切入,重点解析WINCC8.1与Automation License Manager的协同工作原理,详细说明包括系统环境检查、安装包校验、授权文件配置等关键技术环节。针对工程实施中常见的内存配置不足、授权管理器报错等典型问题,提供经过现场验证的解决方案,特别适用于需要进行产线监控系统升级维护

cqwf95925的博客 1651

Android TextView文字横向自动滚动(跑马灯)

在这里我和身边一些朋友特意整理了一份快速进阶为Android高级工程师的系统且全面的学习资料。涵盖了Android初级——Android高级架构师进阶必备的一些学习技能。附上:我们之前因为秋招收集的二十套一二线互联网公司Android面试真题(含BAT、小米、华为、美团、滴滴)和我自己整理Android复习笔记(包含Android基础知识点、Android扩展知识点、Android源码解析、设计模式汇总、Gradle知识点、常见算法题汇总。

2401_84149845的博客 1751

DASH 流媒体协议(Dynamic Adaptive Streaming over HTTP)概述——起源、MPD文件解析、相关项目

简单介绍DASH的起源与发展、MPD文件简要解析、相关项目,以及常见流媒体协议的比较

farewellyi的博客 6884

【计算机视觉】pyrealsense2:Intel RealSense 深度相机的 Python 接口实战指南

pyrealsense2:Intel RealSense 深度相机的 Python 接口实战

weixin_43988131的博客 4350

Android自定义textview实现自动滚动

原本想直接使用Android TextView自带的Marquee效果,但是这个需要控件被选中才会执行跑马灯,而且要文本内容的宽度超出文本控件本身的宽度时才会执行,而项目需要的效果是不管文本内容有多少都要执行滚动效果,所以只能放弃。3. 新加setMarqueeText(int resId)和setMarqueeText(CharSequence text)给外部调用,用于替换TextView的setText()方法。最近项目要实现一个置顶的子串滚动显示,类似广告条,需要悬浮在所有应用上面。

iamjustnobody的博客 1715

死区补偿---学习笔记

最近调试中发现,死区补偿对电流谐波和电流带宽影响挺大,于是对死区补偿产生浓厚兴趣,找来几篇文章粗读并做一下笔记。 传统做法 无非就是根据电流方向补偿,假如svpwm计算出的A相理论导通实践为T1,死区时间是Td,则实际导通时间T = T1-Td(when ia >0 ),于是在svpwm计算出的导通时间T1的基础上加上Td。这样经过PWM模块后,实际的导通时间即为T1. 但存在两个难点(个人总结): 1,受电流检测精度影响,尤其是在过零点检测困难。 2,真实的二极管导通需要一定电压,并非..

圆桌骑士的博客 2万+

Android 实现跑马灯效果

这里可以使用动画的效果实现.init();init();init();});// 停止动画 if(animator!} }init();init();init();});// 停止动画 if(animator!} }Context;init();init();init();

赵航的博客 3万+

拆解歌尔2718硅麦:2.75mm超小封装背后的MEMS技术解析

本文深度解析歌尔2718硅麦的2.75mm超小封装技术,探讨MEMS麦克风在微型化过程中的声学性能与结构可靠性平衡。通过ASIC芯片堆叠、纳米级应力控制等创新技术,歌尔2718在TWS耳机和智能手机中实现卓越性能,同时克服微型化带来的声学挑战。

weixin_28292761的博客 610

一文入门车载以太网:从原理到实战,看完就能上手开发

新手选型遵循“适配场景、兼顾成本、优先车规”的原则:普通场景(车载娱乐、普通诊断):100Base-T1 PHY(LAN8742)+ 非TSN交换机(SJA1105)+ STM32H743 ECU + 普通STP线缆;ADAS场景:1000Base-T1 PHY(TJA1101)+ TSN交换机(SJA1110)+ NXP S32G399 ECU + 高抗干扰STP线缆;避免过度选型:如普通娱乐场景无需选择TSN交换机、ASIL-B级芯片,否则会增加成本;

getusushu的博客 317

【Android】带阴影的TextView实现走马灯效果

TextView学习 基础属性: 名字 含义 layout_width 组件宽度 layout_height 组件高度 id 为TextView设置一个组件id text 设置显示的文本内容 textColor 设置字体颜色(共八位,12代表透明度,34代表红色,56代表绿色,78代表蓝色) textStyle 设置字体风格,三个可选值,normal(无效果),bold(加粗),italic(斜体) textSize 字体大小,单位一般是用sp backgroup

少年白马 1450

【数据分析】R语言分段结构方程模型手把手教程(Piecewise Structural Equation Model)

分段结构方程模型(Piecewise Structural Equation Model, SEM)是一种用于分析变量之间因果关系的统计方法。它通过将复杂的因果关系分解为多个简单的线性模型来评估变量之间的直接和间接效应。与传统的结构方程模型(SEM)不同,分段结构方程模型不需要假设数据的多变量正态分布,因此在处理非正态数据时更为灵活。

专注生信领域 2648

[Android] TextView实现走马灯效果

在TextViw中,如果文本的长度超出了显示范围,可以使文本水平滚动显示,类似于走马灯的效果,只需在XML布局文件中,为TextView设置如下几个属性即可。         android:ellipsize="marquee"。         android:marqueeRepeatLimit="XX"。其中XX表示循环次数,为大于0的整数或marquee_forever(无限循环

Fergus 点滴 3891

MicroPython学习:在STM32上进行移植

本文将介绍如何在STM32上移植MicroPython,并提供相应的源代码。通过以上步骤,你已经成功地将MicroPython移植到STM32上,并可以使用MicroPython语言编写和运行代码。你可以进一步探索MicroPython的功能和API,以利用STM32的各种外设和功能。使用STM32CubeProgrammer或其他适当的烧录工具,将编译生成的MicroPython固件烧录到STM32微控制器中。打开该文件,并根据你的STM32微控制器类型进行必要的配置更改。模块来控制STM32的LED。

JeeVue的博客 1237

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

android中TextView多行文本滚动的实现及单行走马灯实现

TextView当设定行数是单行的时候可以实现走马灯效果,但有时候多行的时候如何实现文本滚动呢,一般方法:NO.1setMovementMethod方法 textView赋值前,调用如下方法即可实现文本滚动,此时是没有滚动条的。 注意一定要在setText之前调用setMovementMethod方法 TextView textView = (TextView)findViewById(R.id

Large_beaR的博客 4309

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

android TextView实现简单的走马灯效果

<TextView android:id="@+id/tvSongName" android:layout_width="200px" android:layout_height="wrap_content" android:layout_marginLeft="46px" ...

你知道的昵称 901

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

安卓实现走马灯效果 textview 实现字体循环滚动效果

安卓开发小效果--走马灯 使在layout 中 实现文字滚动效果 也就是走马灯的效果 只需要在响应控件里面加上这几行代码就可以 1                 android:singleLine="true"             android:ellipsize="marquee"   

智欣约的博客 3166

Android开发之TextView实现走马灯效果

在TextView加以下属性: 1.singleLine=”true”:一行显示所有文本。此属性过期,但用lines=”1”走马灯无效 2.scrollHorizontally=”true”:水平滚动 3.focusable=”true”:可获取焦点 4.focusableInTouchMode=”true”:触屏设备可获取焦点 注意:   若多个TextView要同时实现走马灯效果(...

I am Grooter... 514

Android textview和listview实现水平自动滚动的走马灯效果

当我们遇到需要在一个textview里显示较长文字时候,往往有以下几种考虑:           1.换行,Android里本身也是这样在考虑;           2.可以进行水平或者垂直滑动;           3.采用走马灯效果。           其实这三种要实现都不难,根据实际情况进行选择就是了。不过我在具体实现走马灯时候遇到了一些问题,后来参考了下大神的代码,得以解决,记录

卡小基的博客 1万+

android:TextView实现文字走马灯效果(欺骗系统获取持久的焦点)

通常情况下我们想实现文字的走马灯效果需要在xml文件中这样设置 <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="mar

苏苏爱自由 5172

android中TextView的文字实现动态效果,走马灯效果,闪烁效果

笔者在学习android的过程中曾遇到过一个比较头疼的问题——如何让文本实现走马灯的效果,在起初我和大家一样想在网上找到一点资料,可是当我在茫茫网际中搜寻了几个小时之后发现的结果却是非常恼火的,提问的一大堆却没有回答的,于是我开始自己的专研道路,笔者是一个android的菜鸟级人物,而且是非常菜的那种。在对android自带的例子的学习中我渐渐明白了如何实现走马灯效果了。以下是我自己的一段代码,如

mingxunzh的专栏 2万+

android textview走马灯效果,Android 中TextView中跑马灯效果的实现方法

条件:1、android:ellipsize=”marquee”2、TextView必须单行显示,即内容必须超出TextView大小3、TextView要获得焦点才能滚动mTVText.setText(“超过文本长度的数据");mTVText.setSingleLine(true);设置单行显示mTVText.setEllipsize(TruncateAt.MARQUEE);设置跑马灯显示效果Te...

weixin_39900206的博客 473

android textview 滚动_Android走马灯实现方式,你会了吗?

点击上方蓝字关注?来源:BillyZuohttps://www.jianshu.com/p/2cea4dbac6bd前言效果图:方法一、使用系统控件ViewFlipper方式:布局文件:<ViewFlipperandroid:id="@+id/view_flipper"android:layout_width="300dp"android:layout_height="35dp"...

weixin_39630095的博客 201
上一篇: SharedPreferences的设置保存
下一篇: android 垂直的进度条实现
走丢的猫
博客等级 码龄15年 4粉丝 35原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值