H07000223 / FlycoTabLayout

An Android TabLayout Lib
MIT License
11.05k stars 2.42k forks source link

SlidingTabLayout设置红点 默认显示在左边 #538

Closed EsonH closed 2 years ago

EsonH commented 2 years ago

给SlidingTabLayout设置showDot 源码里注释是说显示在文字右边 但是实际效果是显示在文字左边

timfei commented 2 years ago

请问是如何解决?我默认也显示在左侧了 showMsg

EsonH commented 2 years ago

@timfei

初始化的时候 调用一下下面的方法 重新给msgView设置一下规则就行了 //解决tab均分时 红点显示位置异常的问题 for (i in 0 until tab_consultation.tabCount) { val msgView: MsgView = tab_consultation.getMsgView(i) if (msgView.layoutParams is RelativeLayout.LayoutParams) { val layoutParams = msgView.layoutParams as RelativeLayout.LayoutParams if (msgView.parent is ViewGroup) { val viewGroup = msgView.parent as ViewGroup if (viewGroup.findViewById(R.id.tv_tab_title) is TextView) { val tabTitle = viewGroup.findViewById(R.id.tv_tab_title) tabTitle.setPadding(DisplayUtils.dp2px(4f), 0, DisplayUtils.dp2px(4f), 0) layoutParams.addRule(RelativeLayout.ALIGN_RIGHT, R.id.tv_tab_title) } } } }