改变杰克沃顿的 TitlePagerIndicator 所需的最低工作量是多少? 在您滑动时生成您在Google Play商店中看到的文字淡入效果的效果 标签之间?我认为关键在于修改 onDraw(),但这需要我弄清楚他的代码和数学。如果有一个更简单的解决方案,我宁愿这样做。
我也尝试过 TitlePagerIndicator.setFadingEdgeLength(100),但这似乎没有做任何事情。我知道你必须做 TitlePagerIndicator.setHorizontalFadingEdgeEnabled(true)但是 仍然没有任何褪色效果。
以下是基于Jake样本之一的代码:
public class SampleTitlesStyledMethods extends BaseSampleActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.simple_titles);
mAdapter = new TestTitleFragmentAdapter(getSupportFragmentManager());
mPager = (ViewPager)findViewById(R.id.pager);
mPager.setAdapter(mAdapter);
TitlePageIndicator indicator = (TitlePageIndicator)findViewById(R.id.indicator);
mIndicator = indicator;
indicator.setViewPager(mPager);
final float density = getResources().getDisplayMetrics().density;
indicator.setBackgroundColor(0x18FF0000);
indicator.setFooterColor(0xFFAA2222);
indicator.setFooterLineHeight(1 * density); //1dp
indicator.setFooterIndicatorHeight(3 * density); //3dp
indicator.setFooterIndicatorStyle(IndicatorStyle.Underline);
indicator.setTextColor(0xAA000000);
indicator.setSelectedColor(0xFF000000);
indicator.setSelectedBold(true);
//my code, doesn't seem to do anything though...
indicator.setHorizontalFadingEdgeEnabled(true);
indicator.setFadingEdgeLength(1000);
}
}