Napa Ram
09/23/2021, 4:35 PMnglauber
09/23/2021, 5:07 PMvalues
folder:
<bool name="isTablet">false</bool>
and then, this in values-sw600dp
folder:
<bool name="isTablet">true</bool>
Finally, in your composable:
val isTablet = booleanResource(id = R.bool.isTablet)
if (isTablet) {
// UI for tablet
} else {
// UI for phone
}
Napa Ram
09/23/2021, 5:12 PMNapa Ram
09/23/2021, 5:12 PMnglauber
09/23/2021, 5:21 PMAlex Vanyo
09/23/2021, 6:42 PMisTablet
flag, since I’d argue that isn’t quite the right question to ask.
If your app is running on a tablet, you might have additional space to make use of in your UI. But, if your app is running in multi-window mode on a tablet, you might not have much more space than a “classic” phone does. Android apps running on Chrome OS with free-form windows is another case where your app’s window size might change arbitrarily.
Because of that, I’d try to frame your logic around “here is the space available to me, therefore this is the UI I should show”Alex Vanyo
09/23/2021, 7:04 PMBoxWithConstraints
and then use the maxWidth
and maxHeight
constraints to make decisions.Alex Vanyo
09/23/2021, 7:12 PM