Because there are too many screen aspect ratio styles for android phones, when designing UI, many times, there will be differences in display due to different aspect ratios and resolutions.
I solved it like this
Before the activity's onCreate method, call:
fun screenFit(context: Context) {
val metrics: DisplayMetrics = context.resources.displayMetrics
val td = metrics.heightPixels / 760f
val dpi = (160 * td).toInt()
metrics.density = td
metrics.scaledDensity = td
metrics.densityDpi = dpi
}
so it fits