2012-07-05 50 views
3

什麼的努力來改變傑克沃頓商學院的TitlePagerIndicator 到一個產生,你在谷歌看到Play商店,你之間刷卡 文本漸變效果所需的最低量中的標籤之間揮筆標籤?我認爲關鍵在於修改onDraw()但這需要我弄清楚他的代碼和他的數學。如果有更簡單的解決方案,我更喜歡。如何創建文本漸變效果,當用戶使用PageIndicator

我也試過TitlePagerIndicator.setFadingEdgeLength(100),但這似乎沒有做任何事情。我知道你必須做TitlePagerIndicator.setHorizo​​ntalFadingEdgeEnabled(true)但 仍然沒有任何消退效果。

下面是傑克的樣本的一個基於關代碼:

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); 
    } 
} 
+0

這需要一個答案!你有沒有想到巴尼蕭? – 2012-12-05 19:53:40

回答

1

我知道這是舊的,但你應該檢查答案here這對我來說真是棒極了