https://kotlinlang.org logo
#compose-android
Title
# compose-android
s

Sunil Kumar

09/29/2023, 4:58 AM
Hi everyone, for dimensions > Someone suggested me to use
expect/actual
like this: >
Copy code
expect object Dimensions {
>     val buttonHeight: Dp
>     val smallPadding: Dp
> }
> and on actual for android - use android's dimens resources. in actual for iOS - use size classes by code. in actual for desktop/web - use constants or some that will resolve your task Is this possible to use android's dimens resources in actual implementation of this Dimensions class, I tried but i am not able to access those androidApp dimens resources in kmm androidMain module's actual implemention.
t

Timo Drick

09/29/2023, 8:31 AM
I would recommend to not use the android dimes resource files at all. They are only available in Android. Better to just define this in one kotlin file.
s

Sunil Kumar

09/30/2023, 9:28 AM
Ok thnx
t

Timo Drick

09/30/2023, 9:54 AM
But in theory i would assume that it should be possible to access the resources in android actual implementation.
s

Sunil Kumar

09/30/2023, 10:46 AM
Yea, i was also thinking so, thats why i was trying. But i was not able to access them, dont know why if i type R.dimen.any_item_name, It does not suggest me resources from defined dimens from androidApp, but it suggests few dimensions which are from android library
t

Timo Drick

09/30/2023, 11:06 AM
This happens normally when you do import the wrong R package. Make sure to import the local namespace R file.
s

Sunil Kumar

09/30/2023, 11:11 AM
importing the local ones related to my package,What i mean is that for system dimensions, its showing suggestions, BUt not from local ones
t

Timo Drick

09/30/2023, 12:04 PM
For me it works. Do you use Android Studio or IntelliJ?
I just tested it on the example project https://github.com/JetBrains/compose-multiplatform/tree/master/examples/codeviewer With Android Studio
Maybe you configured some thing wrong? You could use this project to check.
s

Sunil Kumar

09/30/2023, 12:39 PM
Yea may be something is wrong here, i will check it. thnx