全部 文章 问答 分享 共找到14个相关内容
[文章] 【自定义View】自动滚动的TextView(跑马灯)——可获取完成一次滚动后的监听
AutoRollTextViewByRunnable类classAutoRollTextViewByRunnableextendsandroidx.appcompat.widget.AppCompatTextViewimplementsRunnable{StringTAG="MarqueeText";privateintcurrentScrollX=0;//当前滚动的位置privateinttextWidth;privateintviewWidth;privatebooleanisMeasure=false;privatebooleanisRoll=false;AgainListeneragainListener;//动画效果ObjectAnimatoranimator1;ObjectAnimatoranimator2;publicAutoRollTextViewByRunnable(Contextcontext){super(context);init();}publicAutoRollTextViewByRunnable(Contextcontext,AttributeSetattrs){super(context,attrs);init();}publicAutoRollTextViewByRunnable(Contextcontext,AttributeSetattrs,intdefStyle){super(context,attrs,defStyle);init();}voidinit(){setGravity(Gravity.CENTER_VERTICAL);setSingleLine();setEllipsize(TextUtils.TruncateAt.MARQUEE);startScroll();addTextChangedListener(textWatcher);//动画效果animator1=ObjectAnimator.ofFloat(this,"alpha",0f);animator2=ObjectAnimator.ofFloat(this,"alpha",1f);}@OverrideprotectedvoidonDraw(Canvascanvas){super.onDraw(canvas);if(!isMeasure){textWidth=getTextWidth();viewWidth=getWidth();isMeasure=true;}}TextWatchertextWatcher=newTextWatcher(){@OverridepublicvoidbeforeTextChanged(CharSequences,intstart,intcount,intafter){animator1.setDuration(0);animator2.setStartDelay(500);animator2.setDuration(500);animator2.setInterpolator(newLinearInterpolator());AnimatorSetanimatorSet=newAnimatorSet();animatorSet.playSequentially(animator1,animator2);animatorSet.start();}@OverridepublicvoidonTextChanged(CharSequences,intstart,intbefore,intcount){}@OverridepublicvoidafterTextChanged(Editables){textWidth=getTextWidth();}};@Overridepublicvoidrun(){if(textWidth>viewWidth){//需要滚动currentScrollX+=3;scrollTo(currentScrollX,0);if(getScrollX()>textWidth){againListener.Again();currentScrollX=-viewWidth;scrollTo(currentScrollX,0);}postDelayed(this,5);}else{//无需滚动scrollTo(0,0);postDelayed(this,500);}}publicvoidstartScroll(){post(this);}publicvoidstopScroll(){this.removeCallbacks(this);}/***获取文字宽度*/publicintgetTextWidth(){Paintpaint=this.getPaint();Stringstr=this.getText().toString();return(int)paint.measureText(str);}publicAgainListenergetAgainListener(){returnagainListener;}publicvoidsetAgainListener(AgainListeneragainListener){this.againListener=againListener;}interfaceAgainListener{voidAgain();}}2、使用(xml忽略)AutoRollTextViewByRunnablemarqueeText;//完成一次滚动的监听marqueeText.setAgainListener(newAutoRollTextViewByRunnable.AgainListener(){@OverridepublicvoidAgain(){Log.d(TAG,"Again:");}});
[文章] 从零开始实现GridLayout
--每一列之间的纵向间隔--><attrname="verticalSpace"format="integer"/><!
[问答] 如何实现 功德+1木鱼的 动态添加view
https://images.sunofbeaches.com//images/2023_01_09/1612378748830801921.gif">
我个人的理解是 它的轨迹是 横向和纵向平移动画
[文章] 25000字总结Android优秀的第三方框架、各种学习资料(上)
简书花式封装使用SpannableStringGithub简单易用的TextView装饰库TextView特效Github滚动显示TextView的数字,支持自定义每个字符速度Github俗名:可垂直跑、可水平跑的跑马灯
2020-05-18 19:56
·
android
[文章] IDEA-Debug高级技巧
技巧idea至于介绍就看官网就ok了,https://www.jetbrains.com/idea/download/other.html一、基本用法&快捷键Debug主要对应的是横向的一条和纵向的一条
2020-11-22 17:59
·
IDEA
[文章] Paint 画笔高级应用
Bitmapbitmap,Shader.TileModetileX,Shader.TileModetilY)参数:bitmap:用来做模板的Bitmap对象tileX:横向的着色规则,类型是TileModetileY:纵向的着色规则
[文章] 给RecyclerView的item优雅的加上等宽间距
LinearLayoutManager纵向(VERTICAL)第一个item的顶部和左右两边均设置两个单位的间距,底部设置一个单位的间距。
[文章] 自定义一个不一样的 RadioGroup
(纵向)。子类必须是RadioButton,有些样式用RadioButton做起来不是很爽。
[文章] 如何在 Android 中绘制色卡效果
setOrientation(LinearLayoutCompat.HORIZONTAL)}可以看到,我们针对方案4进行了优化,现在我们的自定义drawable支持设置多个颜色,可以按照比例进行绘制,而且可以支持横向和纵向的绘制
- 1