Android 安卓冰淇淋三明治上的Astuetz viewpager
我面临着一个关于冰淇淋三明治的Astuetz Viewpager的小问题。 问题是,在滚动页面时,页面指示器和日期不会消失/改变颜色。 同样的寻呼机,在蜂巢前的设备上,工作起来很有魅力。 有人面临同样的问题吗?我找到了解决办法 我一直在分析Astuetz viewpager库,发现在滚动页面时没有调用包含日期和彩色底部边框的textview的onDraw方法。我们需要对扩展textview的父onLayout方法调用invalidate方法 像这样更改ViewPagerTables类(在for looop中添加tab.invalidate())Android 安卓冰淇淋三明治上的Astuetz viewpager,android,android-viewpager,Android,Android Viewpager,我面临着一个关于冰淇淋三明治的Astuetz Viewpager的小问题。 问题是,在滚动页面时,页面指示器和日期不会消失/改变颜色。 同样的寻呼机,在蜂巢前的设备上,工作起来很有魅力。 有人面临同样的问题吗?我找到了解决办法 我一直在分析Astuetz viewpager库,发现在滚动页面时没有调用包含日期和彩色底部边框的textview的onDraw方法。我们需要对扩展textview的父onLayout方法调用invalidate方法 像这样更改ViewPagerTables类(在for
@覆盖
仅受保护的void布局(布尔值已更改、int l、int t、int r、int b){
最终整数计数=getChildCount();
final int center=this.getMeasuredWidth()/2;
//在此位置,居中选项卡将通过
//ViewPagerTab.setCenterPercent(整数百分比)
final int highlightOffset=this.getMeasuredWidth()/5;
//布置每个选项卡
for(int i=0;i
我一直在分析Astuetz viewpager库,发现包含日期和彩色底框的textview的onDraw方法在滚动页面时没有被调用。我们需要在扩展textview的父onLayout方法上调用invalidate方法
像这样更改ViewPagerTables类(在for looop中添加tab.invalidate())
@覆盖
仅受保护的void布局(布尔值已更改、int l、int t、int r、int b){
最终整数计数=getChildCount();
final int center=this.getMeasuredWidth()/2;
//在此位置,居中选项卡将通过
//ViewPagerTab.setCenterPercent(整数百分比)
final int highlightOffset=this.getMeasuredWidth()/5;
//布置每个选项卡
for(int i=0;i@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int count = getChildCount();
final int center = this.getMeasuredWidth() / 2;
// At this position, the centered tab will be highlighted via
// ViewPagerTab.setCenterPercent(int percent)
final int highlightOffset = this.getMeasuredWidth() / 5;
// lay out each tab
for (int i = 0; i < count; i++) {
final ViewPagerTab tab = (ViewPagerTab) getChildAt(i);
tab.invalidate();
final int tabCenter = tab.layoutPos + tab.getMeasuredWidth() / 2;
int diff = Math.abs(center - tabCenter);
if (diff <= highlightOffset) {
final int x1 = highlightOffset;
final int y = (int) 100 * diff / x1;
tab.setCenterPercent(100 - y);
} else {
tab.setCenterPercent(0);
}
tab.layout(tab.layoutPos, this.getPaddingTop(), tab.layoutPos + tab.getMeasuredWidth(), this.getPaddingTop()
+ tab.getMeasuredHeight());
}
}