android 跑马灯(继承TextView)
来源:互联网 发布:j to e开发java模式 编辑:程序博客网 时间:2024/06/07 19:01
package com.example.administrator.zxqdemo;import android.content.Context;import android.graphics.Canvas;import android.util.AttributeSet;import android.util.Log;import android.view.animation.AccelerateInterpolator;import android.widget.Scroller;import android.widget.TextView;import java.util.List;/** * Created by Administrator on 2016/9/27. */public class RunHorseView extends TextView { private Scroller mScroller; public RunHorseView(Context context) { super(context); } public RunHorseView(Context context, AttributeSet attrs) { super(context, attrs); mScroller=new Scroller(context,new AccelerateInterpolator()); } public RunHorseView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mScroller=new Scroller(context,new AccelerateInterpolator()); } private List<String> listSource; private int size; public void initSource(List<String> listSource) { this.listSource=listSource; size=listSource.size(); } String drawText=""; @Override protected void onDraw(Canvas canvas) { this.setText(drawText); Log.e("dd","ondraw"); super.onDraw(canvas); } int index=0; @Override public void computeScroll() { if(mScroller.computeScrollOffset()) { Log.e("dd","x:"+mScroller.getCurrX()+"y:"+mScroller.getCurrY()); scrollTo(mScroller.getCurrX(),mScroller.getCurrY()); Log.e("dd","compute"); postInvalidate(); }else { drawText=listSource.get(index); startScorll(); index++; index=index%size; } super.computeScroll(); } public void startScorll() { int dy=getHeight()-((int)getTextSize())/2; Log.e("dy","dy:"+dy); mScroller.startScroll(0,0,0,dy,2000); Log.e("dd","start"); invalidate(); }}//调用过程RunHorseView runHorseView= (RunHorseView) findViewById(R.id.runHorse);List<String> list=new ArrayList<>();list.add("张三 你中了5000000");list.add("李四 你中了5000000");list.add("王五 你中了5000000");list.add("孙六 你中了5000000");list.add("钱七 你中了5000000");list.add("周八 你中了5000000");runHorseView.initSource(list);runHorseView.startScorll();
0 0
- android 跑马灯(继承TextView)
- android TextView跑马灯
- Android TextView跑马灯
- Android TextView跑马灯
- Android TextView 跑马灯
- Android中继承TextView实现文字的跑马灯效果
- Android TextView跑马灯效果
- android的textView跑马灯
- Android TextView跑马灯效果
- Android TextView跑马灯效果
- Android TextView跑马灯效果
- [Android]TextView跑马灯效果
- android--TextView实现跑马灯
- android 自定义TextView跑马灯
- Android:TextView跑马灯详解
- Android textView 跑马灯效果
- android TextView 跑马灯效果
- Android TextView跑马灯效果
- JAVA正则表达式 Pattern和Matcher
- linux 安装nodejs
- Android 延时执行某个任务
- AndroidManifest中的android:allowBackup属性
- android gralloc 流程分析
- android 跑马灯(继承TextView)
- 51NOD 1276 岛屿的数量
- R语言|求ROC和AUC值
- 套接字
- JPA映射Map的问题
- AndroidApk混淆编译时,报告java.io.IOException: The same input jar[xxx/xxx.jar]is specified twice.
- 制表符
- Android分包MultiDex原理详解
- 当你在浏览器地址栏输入一个URL后回车,将会发生的事情?