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

Commit cf355aa

Browse files
committed
Fixed a case in which the title was being truncated
When using multiple lines in the title, the text is being truncated at the top due to the top margin being set to a negative margin. Now only adding the margin when the value is not negative.
1 parent ee442c3 commit cf355aa

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)