JakeWhartonTitlePageIndicatorを使用しています。タイトルを少し長い文字列(20文字)に設定するまで、インジケーターは非常にうまく機能しました。中央のタイトルは非常によく表示されますが、左右のタイトルが中央のタイトルに近すぎます。左右のタイトルが半分(または固定長)しか表示されないGoogle Playのようにする方法はありますか?
ありがとうございました、
JakeWhartonTitlePageIndicatorを使用しています。タイトルを少し長い文字列(20文字)に設定するまで、インジケーターは非常にうまく機能しました。中央のタイトルは非常によく表示されますが、左右のタイトルが中央のタイトルに近すぎます。左右のタイトルが半分(または固定長)しか表示されないGoogle Playのようにする方法はありますか?
ありがとうございました、
これと同じ問題を抱えている可能性のある人のために。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に渡すことができます。ここでは、理解しやすいようにハードコーディングしました。
そのようにライブラリを変更する必要はありません。TitlePageIndicatorにclipPaddingを指定するだけです。
そのように:
mIndicator.setClipPadding(-60);