Skip to content

Commit

Permalink
Merge pull request #77 from siralam/master
Browse files Browse the repository at this point in the history
SimplePagerTitleView now returns correct ContentLeft and ContentRight…
  • Loading branch information
hackware1993 authored Dec 26, 2018
2 parents ec20414 + 5d87f53 commit 6d1c490
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,16 @@ public void onEnter(int index, int totalCount, float enterPercent, boolean leftT
@Override
public int getContentLeft() {
Rect bound = new Rect();
getPaint().getTextBounds(getText().toString(), 0, getText().length(), bound);
String longestString = "";
if (getText().toString().contains("\n")) {
String[] brokenStrings = getText().toString().split("\\n");
for (String each : brokenStrings) {
if (each.length() > longestString.length()) longestString = each;
}
} else {
longestString = getText().toString();
}
getPaint().getTextBounds(longestString, 0, longestString.length(), bound);
int contentWidth = bound.width();
return getLeft() + getWidth() / 2 - contentWidth / 2;
}
Expand All @@ -69,7 +78,16 @@ public int getContentTop() {
@Override
public int getContentRight() {
Rect bound = new Rect();
getPaint().getTextBounds(getText().toString(), 0, getText().length(), bound);
String longestString = "";
if (getText().toString().contains("\n")) {
String[] brokenStrings = getText().toString().split("\\n");
for (String each : brokenStrings) {
if (each.length() > longestString.length()) longestString = each;
}
} else {
longestString = getText().toString();
}
getPaint().getTextBounds(longestString, 0, longestString.length(), bound);
int contentWidth = bound.width();
return getLeft() + getWidth() / 2 + contentWidth / 2;
}
Expand Down

0 comments on commit 6d1c490

Please sign in to comment.