更改 Jake Wharton 的 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);
}
}
最佳答案
我知道这是旧的,但你应该检查答案 here它对我很有用
关于java - 如何在用户使用 PageIndicator 跨选项卡滑动时创建文本淡入淡出效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11350836/