0

JakeWhartonTitlePageIndicatorを使用しています。タイトルを少し長い文字列(20文字)に設定するまで、インジケーターは非常にうまく機能しました。中央のタイトルは非常によく表示されますが、左右のタイトルが中央のタイトルに近すぎます。左右のタイトルが半分(または固定長)しか表示されないGoogle Playのようにする方法はありますか?

ありがとうございました、

4

2 に答える 2

2

これと同じ問題を抱えている可能性のある人のために。JakeWharton TitlePageIndicatorには、左右のタイトルの表示を制御する2つのメソッドがあります。

/**
 * Set bounds for the right textView including clip padding.
 *
 * @param curViewBound
 *            current bounds.
 * @param curViewWidth
 *            width of the view.
 */
private void clipViewOnTheRight(Rect curViewBound, float curViewWidth, int right) {
    // isShowPartOfInactiveTitles is my variable which is set default to TRUE
    if(isShowPartOfInactiveTitles){
        curViewBound.right = (int)(right + curViewWidth - 60);
        curViewBound.left = (int)(right - 60);
    }else{
        curViewBound.right = (int) (right - mClipPadding);
        curViewBound.left = (int) (curViewBound.right - curViewWidth);
    }
}

/**
 * Set bounds for the left textView including clip padding.
 *
 * @param curViewBound
 *            current bounds.
 * @param curViewWidth
 *            width of the view.
 */
private void clipViewOnTheLeft(Rect curViewBound, float curViewWidth, int left) {
    // isShowPartOfInactiveTitles is my variable which is set default to TRUE
    if(isShowPartOfInactiveTitles){
        curViewBound.left = (int)(left - curViewWidth + 60);
        curViewBound.right = (int)(left + 60);
    }else{
        curViewBound.left = (int) (left + mClipPadding);
        curViewBound.right = (int) (mClipPadding + curViewWidth);   
    }
}

上記のコードスニペットには、60dpの左右のタイトルのみが表示されます。この番号を属性にして、xmlに渡すことができます。ここでは、理解しやすいようにハードコーディングしました。

于 2013-01-09T07:08:34.067 に答える
2

そのようにライブラリを変更する必要はありません。TitlePageIndicatorにclipPaddingを指定するだけです。

そのように:

mIndicator.setClipPadding(-60);
于 2013-02-21T13:21:55.577 に答える