Colton Idle
01/08/2024, 11:18 PMDisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int widthDp = (int) (metrics.widthPixels / metrics.density);
int heightDp = (int) (metrics.heightPixels / metrics.density);
Trying to convert the following to a compose app
https://github.com/googlemaps/android-maps-utils/blob/main/demo/src/main/java/com/google/maps/android/utils/demo/VisibleClusteringDemoActivity.javaColton Idle
01/08/2024, 11:18 PMval configuration = LocalConfiguration.current
val screenHeight = configuration.screenHeightDp
val screenWidth = configuration.screenWidthDp
or should I use boxWithConstraints?Colton Idle
01/08/2024, 11:19 PMromainguy
01/08/2024, 11:22 PMromainguy
01/08/2024, 11:23 PMromainguy
01/08/2024, 11:23 PMromainguy
01/08/2024, 11:23 PMColton Idle
01/08/2024, 11:24 PMromainguy
01/08/2024, 11:26 PMColton Idle
01/08/2024, 11:27 PMColton Idle
01/08/2024, 11:28 PMromainguy
01/08/2024, 11:29 PMColton Idle
01/08/2024, 11:31 PMColton Idle
01/08/2024, 11:32 PMromainguy
01/08/2024, 11:38 PMModifier.onGloballyPositioned
Colton Idle
01/08/2024, 11:39 PMromainguy
01/09/2024, 12:02 AMromainguy
01/09/2024, 12:03 AMonGloballyPositioned
on the AndroidView
(or Surface
)Zach Klippenstein (he/him) [MOD]
01/09/2024, 12:45 AMonSizeChanged
should work too, much cheaper than onGloballyPositioned
if you’re just reading the sizeColton Idle
01/09/2024, 12:47 AMandrew
01/09/2024, 7:12 AMefemoney
01/09/2024, 11:20 AMshikasd
01/09/2024, 11:26 AMColton Idle
01/09/2024, 2:59 PMColton Idle
01/09/2024, 3:00 PMshikasd
01/09/2024, 3:01 PMColton Idle
01/09/2024, 6:41 PMColton Idle
01/09/2024, 6:42 PMAlex Vanyo
01/09/2024, 6:48 PMWindowMetricsCalculator
via a snippet like https://github.com/google/accompanist/pull/1576 in Compose.
You almost never want the physical screen size from displayMetrics
, since your app could be in a smaller window, and LocalConfiguration.current.screenWidthDp/screenHeightDp
are not the size of the window for a few reasons.Colton Idle
01/09/2024, 9:59 PM