全部 文章 问答 分享 共找到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:");}});
2020-07-28 15:57 · TextView / Android / 跑马灯 / 自定义View
[文章] Android开发TextView阴影设置
TextView就可以设置阴影相关参数xml上设置属性Java代码设置参数说明:shadowColor:阴影的颜色shadowDx:横向偏移量shadowDy:纵向偏移量shadowRadius:阴影大小
2022-08-02 10:46 · TextView / 阴影 / Shadow / android开发 / 文本阴影
[文章] 从零开始实现GridLayout
--每一列之间的纵向间隔--><attrname="verticalSpace"format="integer"/><!
[问答] 如何实现 功德+1木鱼的 动态添加view
https://images.sunofbeaches.com//images/2023_01_09/1612378748830801921.gif">

我个人的理解是 它的轨迹是 横向和纵向平移动画

2023-01-09 17:27 · Android / 功德+1 / 动画 / 移动开发
[文章] 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:纵向的着色规则
2022-02-17 09:33 · 安卓 / Android / Paint / 画笔
[文章] 给RecyclerView的item优雅的加上等宽间距
LinearLayoutManager纵向(VERTICAL)第一个item的顶部和左右两边均设置两个单位的间距,底部设置一个单位的间距。
1970-01-01 00:00 · Android / 安卓 / RecyclerView / 装饰 / 间距
[文章] 自定义一个不一样的 RadioGroup
纵向)。子类必须是RadioButton,有些样式用RadioButton做起来不是很爽。
2023-02-07 00:31 · Android / 安卓 / Kotlin / 自定义控件 / RadioGroup
[文章] 如何在 Android 中绘制色卡效果
setOrientation(LinearLayoutCompat.HORIZONTAL)}可以看到,我们针对方案4进行了优化,现在我们的自定义drawable支持设置多个颜色,可以按照比例进行绘制,而且可以支持横向和纵向的绘制
2023-01-13 13:18 · Android / 安卓 / Kotlin / 色卡 / 自定义Drawable
[文章] 3、Android开发基础-线性布局(视频)
既然可以横向,那怎么样才可以纵向呢?
2019-10-21 17:02 · android / 安卓 / 基础 / 布局 / UI
[文章] 安卓(android)屏幕适配
分辨率其实是指屏幕横向和纵向上的像素点,单位是像素(PX),1px表示的是一个像素点。比如说,320*480!4.屏幕像素密度:看过刘翔的手机测评吗?
2019-08-31 10:27 · 安卓 / 屏幕适配 / android / 安卓开发 / 教程
[文章] 自定义控件之SlideMenu-仿QQ侧滑功能菜单
=abs(endX-mInterceptDownX)//在垂直方向移动的位移valdistanceY=abs(endY-mInterceptDownY)//如果横向的滑动距离大于系统认为的滑动距离,且纵向的滑动距离小于系统认为的滑动距离则自己消费
[文章] 有空来撸一只图片浏览器?power by vue.js
宽高复原detailIv.style.height=this.originalHeight+'px';ivHeight=detailIv.height;ivWidth=detailIv.width;//纵向
2022-06-12 13:30 · 组件 / vue.js / nuxt.js / 图片预览 / 摸鱼君
  • 1