3

Jake WhartonのTitlePagerIndicator を、タブ間をスワイプしたときにGooglePlayストアに表示されるテキストフェージング効果を生成するものに変更するために必要な最小限の労力はどれくらいですか。重要なのはonDraw()の変更にあると思いますが、それには彼のコードと数学を理解する必要があります。もっと簡単な解決策があれば、私はそれを好むでしょう。

TitlePagerIndicator.setFadingEdgeLength(100)も試しましたが、何も起こらないようです。TitlePagerIndicator.setHorizo​​ntalFadingEdgeEnabled(true)を実行する必要があることは承知していますが、それでもフェージング効果はまったくありません。

Jakeのサンプルの1つに基づくコードは次のとおりです。

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);
    }
}
4

1 に答える 1

1

私はこれが古いことを知っていますが、ここで答えを確認する必要があります

于 2013-04-15T14:13:17.213 に答える