android 上下跑马灯,GitHub - ronghao/AutoScrollTextView: android 上下滚动播放与走马灯效果结合...

android 上下滚动播放与走马灯效果结合,暂时只支持textview

实现原理

使用scrollTo(x,y)和runable循环调用,移动textview,形成走马灯效果

单个页面多个滚动效果会卡顿问题:由于handler的消息队列机制,导致滚动需要等待上一个message处理完成,现改为线程池ScheduledExecutorService

演示

sample.gif

项目添加方法

在根 build.gradle中添加

allprojects {

repositories {

...

maven { url 'https://jitpack.io' }

}

}

在项目build.gradle中添加 68747470733a2f2f6a69747061636b2e696f2f762f726f6e6768616f2f4175746f5363726f6c6c54657874566965772e737667

dependencies {

compile 'com.github.ronghao:AutoScrollTextView:1.0.3'

}

使用

只有左右滚动

android:id="@+id/main_marguee_text"

android:layout_width="match_parent"

android:layout_height="20dp"

/>

左右滚动加上下滚动

android:id="@+id/main_autoscroll_text1"

android:layout_width="match_parent"

android:layout_height="20dp"

/>

自定义文本样式

继承BaseScrollTextView,在继承类中实现makeTextView()方法中,自定义效果

@Override

public MarqueeTextView makeTextView() {

MarqueeTextView textView = new MarqueeTextView(getContext());

textView.setTextColor(getResources().getColor(R.color.colorAccent));

return textView;

}

一些方法

方法

解释

startAutoScroll

AutoScrollTextView

开始滚动

stopAutoScroll

AutoScrollTextView

停止滚动

makeTextView

AutoScrollTextView

创建一个内部可横向滚动的textview

setOnItemClickListener

AutoScrollTextView

设置点击事件回调

setTextList

AutoScrollTextView

设置数据源

startScroll

MarqueeTextView

开始滚动

postStartScroll

MarqueeTextView

延迟开始滚动

stopScroll

MarqueeTextView

停止滚动

setSpeed

MarqueeTextView

设置速度

setMarqueeListener

MarqueeTextView

设置单个走马灯的开始和结束回调

版本更新说明

1.0.3

添加MarqueeTextViewForViewPager类,临时解决Jars-of-jam-Scheduler的问题

1.0.2

解决单个页面多个滚动效果会卡顿问题

关于

如果你也喜欢这个库,Star一下吧,欢迎Fork

License

Copyright 2016 haohaohu

Licensed under the Apache License, Version 2.0 (the "License");

you may not use this file except in compliance with the License.

You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an "AS IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值