Skip to content
This repository was archived by the owner on Aug 22, 2020. It is now read-only.

Commit 25d7ead

Browse files
authored
Merge pull request #20 from alexkok/master
Fixed a case in which the title was being truncated
2 parents ee442c3 + cf355aa commit 25d7ead

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

library/src/main/java/moe/feng/common/stepperview/VerticalStepperItemView.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,12 @@ private void prepareViews(@NonNull Context context) {
162162
@Override
163163
public void onGlobalLayout() {
164164
int singleLineHeight = mTitleText.getMeasuredHeight();
165-
ViewGroup.MarginLayoutParams mlp = (MarginLayoutParams) mTitleText.getLayoutParams();
166-
mlp.topMargin = (mPointFrame.getMeasuredHeight() - singleLineHeight) / 2;
165+
int topMargin = (mPointFrame.getMeasuredHeight() - singleLineHeight) / 2;
166+
// Only update top margin when it is positive, preventing titles being truncated.
167+
if (topMargin > 0) {
168+
ViewGroup.MarginLayoutParams mlp = (MarginLayoutParams) mTitleText.getLayoutParams();
169+
mlp.topMargin = topMargin;
170+
}
167171
}
168172
});
169173
}

0 commit comments

Comments
 (0)