Search code examples
androidkotlinkotlin-interop

Calling inner class in the parent not working in kotlin


I was in process of converting a java project to kotlin when I encountered this strange behavior.

in Java:

new ImageSwitcher.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

works fine.

but in kotlin it gives me compile error:

ImageSwitcher.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)


LayoutParams is an inner class in `FrameLayout` which is the parent of `ImageSwitcher`

enter image description here

I know I can solve it by using FrameLayout.LayoutParams but why the original code is not working?


Solution

  • There is no static inheritance in kotlin, and i guess this is the right way to go because static inheritance may lead to ambigous errors.