Bimba.git

ref: 5cb16913cd9ec8d0c721b7a7c7731ba3a35d52fc

app/src/main/java/ml/adamsprogs/bimba/utils.kt


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
package ml.adamsprogs.bimba

import android.content.res.Resources
import android.util.DisplayMetrics
import kotlin.math.roundToInt

fun dpToPixel(dp: Float): Float {
	val metrics: DisplayMetrics = Resources.getSystem().displayMetrics
	return dp * (metrics.densityDpi / 160f)
}

fun dpToPixelI(dp: Float): Int = dpToPixel(dp).roundToInt()