This commit is contained in:
Chumva 2019-10-25 13:17:42 +03:00
parent 1b64dd1569
commit 459bd14370
2 changed files with 16 additions and 3 deletions

View file

@ -388,13 +388,18 @@ public class AndroidUtils {
: ctx.getResources().getColor(R.color.text_color_secondary_light));
}
public static int getTextWidth(float textSize, String text) {
Paint paint = new Paint();
paint.setTextSize(textSize);
return (int) paint.measureText(text);
}
public static int getTextHeight(Paint paint) {
Paint.FontMetrics fm = paint.getFontMetrics();
float height = fm.bottom - fm.top;
return (int) height;
}
public static int dpToPx(Context ctx, float dp) {
Resources r = ctx.getResources();
return (int) TypedValue.applyDimension(

View file

@ -3,7 +3,6 @@ package net.osmand.plus.routepreparationmenu;
import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
@ -550,6 +549,15 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
view.setOnClickListener(listener);
Activity activity = getActivity();
if (activity != null) {
TextView title = view.findViewById(R.id.title);
TextView description = view.findViewById(R.id.description);
int titleHeight = AndroidUtils.getTextHeight(title.getPaint());
int descriptionHeight = AndroidUtils.getTextHeight(description.getPaint());
int minTextHeight = titleHeight + descriptionHeight * 2;
if (view.getHeight() < minTextHeight) {
view.setMinimumHeight(minTextHeight);
}
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams();
if (AndroidUiHelper.isOrientationPortrait(getActivity())) {
layoutParams.width = (int) (AndroidUtils.getScreenWidth(activity) / 2.5);