mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
Change overlay icon size according to density
Signed-off-by: Alper Ozturk <alperozturk@lions-macbook.local> Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
6ae12b0e49
commit
a0083b9afb
1 changed files with 11 additions and 2 deletions
|
@ -1,9 +1,12 @@
|
|||
package com.owncloud.android.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.view.Gravity
|
||||
import androidx.core.graphics.drawable.DrawableCompat
|
||||
import com.nextcloud.utils.extensions.isLowDensityScreen
|
||||
import com.nextcloud.utils.extensions.setLayerSizeWithInsetTop
|
||||
|
||||
class DrawableUtil {
|
||||
|
||||
|
@ -13,10 +16,16 @@ class DrawableUtil {
|
|||
return drawable
|
||||
}
|
||||
|
||||
fun addDrawableAsOverlay(backgroundDrawable: Drawable, overlayDrawable: Drawable, topMargin: Int = 3): LayerDrawable {
|
||||
fun addDrawableAsOverlay(context: Context, backgroundDrawable: Drawable, overlayDrawable: Drawable): LayerDrawable {
|
||||
val isLowDensityScreen = context.resources.displayMetrics.isLowDensityScreen()
|
||||
|
||||
val overlayIconSize = if (isLowDensityScreen) { 12 } else { 24 }
|
||||
val overlayIconTopMargin = if (isLowDensityScreen) { 3 } else { 6 }
|
||||
|
||||
val layerDrawable = LayerDrawable(arrayOf(backgroundDrawable, overlayDrawable))
|
||||
layerDrawable.setLayerSizeWithInsetTop(1, overlayIconSize, overlayIconTopMargin)
|
||||
layerDrawable.setLayerGravity(1, Gravity.CENTER)
|
||||
layerDrawable.setLayerInsetTop(1, topMargin)
|
||||
|
||||
return layerDrawable
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue