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