Seekbar存在padding的问题
seekbar默认是存在padding的,如果需要去掉padding使之充满整个seekbar的宽高的话,参考如下配置
<SeekBar
android:id="@+id/videoSeekbar"
android:layout_width="match_parent"
android:layout_height="40dp"
android:maxHeight="40dp"
android:minHeight="0dp"
android:paddingEnd="0dp"
android:paddingStart="0dp"
android:progressDrawable="@drawable/video_seekbar_progress"
android:thumb="@null" />
TabLayou切换Tab的问题
问题描述:
类似淘宝的商品详情页的功能,在滑动详情的时候,tab会动的切换到宝贝、评价、详情、推荐等位置,当用RecyclerView+TabLayout实现此功能的时候,TabLayout的在切换的时候是存在动画的,所以不能在滑动的过程中快速的改变位置。
解决思路:
首先想到了TabLayout+ViewPager实现的时候,当ViewPager调用setcurrentItem方法的时候,能够导致TabLayout快速的切换相应的tab,所以经过查看源码,找到了问题的源头就是下面这个方法:
![](https://img.haomeiwen.com/i177857/45d513f6c44e536e.png)
最后就通过反射的方法来实现了在滑动RecyclerView的时候快速切换TabLayout而不走动画。
解决方法:
public void selectTab(int position) {
try {
Method method =
TabLayout.class.getDeclaredMethod("setScrollPosition", Integer.TYPE,Float.TYPE,Boolean.TYPE);
method.setAccessible(true);
method.invoke(mTablayout, position,0f,true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
网友评论