-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PWN-8992 - make utils to get drawable with needed sizes to fix issues…
… with icon size on UiKitStartAmountView.kt
- Loading branch information
kabramovp2p
committed
Jun 26, 2023
1 parent
d39c67c
commit 02d517c
Showing
3 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.p2p.wallet.utils | ||
|
||
import androidx.annotation.Dimension | ||
import androidx.annotation.DrawableRes | ||
import androidx.appcompat.content.res.AppCompatResources | ||
import android.content.Context | ||
import android.graphics.drawable.Drawable | ||
import android.graphics.drawable.LayerDrawable | ||
|
||
object DrawableUtils { | ||
fun getDrawableWithSizes( | ||
context: Context, | ||
@DrawableRes drawableId: Int, | ||
@Dimension(unit = Dimension.DP) | ||
width: Int, | ||
@Dimension(unit = Dimension.DP) | ||
height: Int, | ||
): Drawable? { | ||
val drawable = AppCompatResources.getDrawable(context, drawableId) ?: return null | ||
return getResizedDrawableUsingSpecificSize(drawable, width, height) | ||
} | ||
|
||
private fun getResizedDrawableUsingSpecificSize(drawable: Drawable, newWidth: Int, newHeight: Int): LayerDrawable { | ||
return LayerDrawable(arrayOf(drawable)).also { it.setLayerSize(0, newWidth, newHeight) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters