mirror of
https://github.com/SimpleMobileTools/Simple-Launcher.git
synced 2025-06-05 21:59:15 +02:00
set proper widget sizes, divide them by density
This commit is contained in:
@ -465,11 +465,15 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
|||||||
val widgetWidth = item.getWidthInCells() * cellWidth
|
val widgetWidth = item.getWidthInCells() * cellWidth
|
||||||
val widgetHeight = item.getHeightInCells() * cellHeight
|
val widgetHeight = item.getHeightInCells() * cellHeight
|
||||||
|
|
||||||
|
val density = context.resources.displayMetrics.density
|
||||||
|
val widgetDpWidth = (widgetWidth / density).toInt()
|
||||||
|
val widgetDpHeight = (widgetHeight / density).toInt()
|
||||||
|
|
||||||
if (isSPlus()) {
|
if (isSPlus()) {
|
||||||
val sizes = listOf(SizeF(widgetWidth.toFloat(), widgetHeight.toFloat()))
|
val sizes = listOf(SizeF(widgetDpWidth.toFloat(), widgetDpHeight.toFloat()))
|
||||||
widgetView.updateAppWidgetSize(Bundle(), sizes)
|
widgetView.updateAppWidgetSize(Bundle(), sizes)
|
||||||
} else {
|
} else {
|
||||||
widgetView.updateAppWidgetSize(Bundle(), widgetWidth, widgetHeight, widgetWidth, widgetHeight)
|
widgetView.updateAppWidgetSize(Bundle(), widgetDpWidth, widgetDpHeight, widgetDpWidth, widgetDpHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
widgetView.layoutParams?.width = widgetWidth
|
widgetView.layoutParams?.width = widgetWidth
|
||||||
|
Reference in New Issue
Block a user