Android文字长度未超过屏幕宽度也可以滚动的TextView

Android文字自动横向滚动的TextView(文字长度不够也可以) Android自带的跑马灯效果,文字长度没有超过屏幕宽度时不会自动滚动,但是我们的需求是文字长度不够也要可以自动滚动。我看了一个人的博客(忘记是谁了,不好意思)他写的也是和Android跑马灯效果差不多的TextView,我在他的基础上改动了一下。我的主要思路是利用handler循环发送消息,不断的调用 invalidate()方法drawText从而达到文字移动效果。关键点是文字整个移出屏幕的 阅读详情

Android自带的跑马灯效果文字长度没有超过屏幕的话不会滚动,但是我们这边产品需求是文字长度没有超过屏幕长度也需要滚动,我看了一个人的博客上实现了Android跑马灯的效果从他博客上获得了灵感,自己改动了一下。其实很简单就是利用handler循环发送消息,不断的调用invalidate()方法drawText从而达到文字滚动的效果。关键地方是当文字整个移出屏幕时我们需要吧x坐标置为屏幕宽度,这样文字才能循环滚动。

public class MarqueeTextView extends TextView {
    /** 是否停止滚动 */
    private boolean mStopMarquee;
    private String mText;
    private float mCoordinateX;
    private float mTextWidth;
    private float windowWith;

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


    public void setText(String text) {
        this.mText = text;
        mTextWidth = getPaint().measureText(mText);
        DisplayMetrics displayMetrics 
Android循环文字滚动TextView实现方法 在Android开发中,经常需要根据特定需求定制UI组件。对于TextView来说,标准的滚动效果可能并不总是满足所有的设计需求。这时,我们可以创建一个自定义的TextView类,通过继承原生TextView类并重写相关方法,来实现更加复杂和个性化的滚动效果。首先,我们创建一个新的Java类,名为。这个类将继承自TextView,并且重写onMeasure方法和onDraw方法来控制文本的滚动。// 构造函数// 重写onMeasure方法来设置滚动参数。 阅读详情

相关推荐

Android自定义自动滚动TextView实战详解

在Android开发中,原生TextView虽提供了基础的文字渲染能力,但面对复杂的动态文本展示需求——如垂直自动滚动、水平无限滑动等场景——其内置功能显得力不从心。尤其当内容超出可视区域且无法依赖用户交互时,如何通过自定义控件实现流畅、可控、低耗的自动滚动行为,成为提升用户体验的关键技术点。为此,构建一个名为的自定义组件,不仅需要深入理解Canvas绘制流程与Layout排版机制,还需精准掌控动画驱动逻辑和状态管理策略。

weixin_31869917的博客 878

文字自动滚动TextView(长度不够也可以)

TextView跑马灯效果,文字长度达不到屏幕宽度也可以。

textview(跑马灯效果)文字长短不限循环播放

textview显示跑马灯效果,使用的是继承的方法onDraw不停地绘制 优点: 1.文字长短不限哦 2.不用非得获取焦点哦

GIS图片地理配准与边界矢量化实操指南:从原理到QGIS应用

图片数字化是GIS数据生产中的基础环节,而将扫描图纸、历史影像等栅格数据转化为可分析空间数据,离不开地理配准与边界矢量化两大核心操作。地理配准通过建立像素坐标与真实地理坐标的映射关系,配合合理分布的控制点与合适的变换模型,消除图像形变并赋予空间位置;矢量化则在此基础上将栅格边界转换为点线面要素。二者结合不仅提升数据精度,还为后续叠加分析、面积量算提供可靠基础,广泛应用于国土规划、历史地图数字化和设计图纸入库等场景。本文以QGIS为工具,系统拆解从坐标系选择、控制点采集到影像输出检查的完整配准流程,并对比自动

weixin_26834281的博客 324

为R720安装iDRAC Service Module

这玩意找了好久资料, 教程都不咋靠谱, 要不就是有不理解的地方 所以直接一路莽着过河: 去官网找到设备对应的驱动程序: 几个查找筛选项看图 官网链接: https://www.dell.com/support/home/zh-cn/product-support/product/poweredge-r720/drivers 在下方的列表中找到对应系统版本的驱动并下载: 由于安装的系统为ESXi 6.5 U2 Dell定制版, 这里没有刚好的驱动, 所以下了个兼容的: 下载好后是一个压缩包:

Janus 6372

unity 在透明物体上投射阴影

unity版本:2019.4.16 创建一个shader,代码如下: Shader "ChuckLee/ARShadow" { Properties { _ShadowColor("Shadow Color", Color) = (0.1, 0.1, 0.1, 0.53) } SubShader { Tags{ "RenderType" = "Transparent" "Queue" = "Geometry+1" } Blend SrcAlpha OneMinusSrcAlph

Abel02的博客 2963

InternVL 3.5 深度解析:开源多模态模型的新里程碑

InternVL 3.5是由上海人工智能实验室OpenGVLab团队推出的开源多模态大模型,在推理能力、效率和灵活性方面取得突破。该模型采用ViT-MLP-LLM架构,包含60亿参数的InternViT-6B视觉编码器和多种规格的语言模型骨干。核心创新包括:1)Cascade RL强化学习框架,通过离线热身和在线强化两阶段训练提升推理能力;2)ViR视觉分辨率路由器,动态调整图像处理分辨率以优化计算效率;3)DvD动态视觉token压缩技术。模型系列涵盖2B到241B参数规模,满足从边缘设备到高性能计算的不

m0_47999117的博客 1045

GPMC开发笔记(TI开发者推荐笔记)

因为gpmc(General-Purpose Memory Controller)是TI特有的驱动,gpmc的资料比较少,本人开发gpmc驱动算是摸了很多石头过河的。所以想通过这遍文章可以给也做GPMC驱动开发的后来者有一点参考价值。文章如有瑕疵也请各位批评改正。 1.GPMC介绍 gpmc主要用于与nandflash,norflash,fpga进行通信。在这里主要介绍gpmc16位数据和地址线不复用nor模式下的通信。 注意:在这种模式下gpmc_a[0]引脚是没法使用的 1.1GPMC信号线

weixin_44316996的博客 7528

华为S5700三层交换机VLAN配置避坑指南:为什么你的VLAN间无法互通?

本文针对华为S5700三层交换机VLAN间无法互通的典型故障,提供深度排障指南。文章从数据转发原理入手,系统梳理了从物理链路、VLAN配置、VLANIF接口状态、路由表到ARP表、MTU及安全策略等全链路检查点,并给出了清晰的排查命令与流程,帮助网络工程师快速定位并解决VLAN间路由问题,实现稳定互通。

tt34567的博客 886

FISCO BCOS 三、多群组部署以及新节点加入群组

本章主要以星形组网和并行多组组网拓扑为例,指导您了解如下内容:了解如何使用创建多群组区块链安装包;了解创建的多群组区块链安装包目录组织形式;学习如何启动该区块链节点,并通过日志查看各群组共识状态;学习如何向各群组发送交易,并通过日志查看群组出块状态;了解群组内节点管理,包括节点入网、退网等;了解如何新建群组。

qq_63235624的博客 2930

2025年7月12日全国青少年信息素养大赛图形化(Scratch)编程小学低年级组复赛真题+答案解析

2025年7月12日全国青少年信息素养大赛图形化(Scratch)编程小学低年级组复赛真题+答案解析

伶俐角少儿编程 722

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

深度学习工具包 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_lover_long
博客等级 码龄11年 0粉丝 1原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值