Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
newApi
  • Loading branch information
forrestguice committed Mar 1, 2024
1 parent 9434e7e commit 5edf852
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,17 @@ public static int getLineCount(@NonNull Context context, @NonNull String text, f

public static StaticLayout getStaticLayout(String text, TextPaint textPaint, int maxWidth)
{
//return new StaticLayout(text, textPaint, maxWidth, Layout.Alignment.ALIGN_CENTER, 1f, 0f, true);
StaticLayout.Builder builder = StaticLayout.Builder.obtain(text, 0, text.length(), textPaint, maxWidth);
builder.setAlignment(Layout.Alignment.ALIGN_CENTER);
builder.setIncludePad(true);
builder.setLineSpacing(0, 1); // 0,1 defaults
return builder.build();
if (Build.VERSION.SDK_INT >= 23)
{
StaticLayout.Builder builder = StaticLayout.Builder.obtain(text, 0, text.length(), textPaint, maxWidth);
builder.setAlignment(Layout.Alignment.ALIGN_CENTER);
builder.setIncludePad(true);
builder.setLineSpacing(0, 1); // 0,1 defaults
return builder.build();

} else {
return new StaticLayout(text, textPaint, maxWidth, Layout.Alignment.ALIGN_CENTER, 1f, 0f, true);
}
}

}

0 comments on commit 5edf852

Please sign in to comment.