Just curious, or what are you trying to accomplish?
Preview uses a library called LayoutLib - I think the code is here:
https://android.googlesource.com/platform/frameworks/layoutlib/+/refs/heads/master
LayoutLib basically tries to emulate the Android APIs. Fair warning, trying to use layoutlib yourself is hard and not for the faint of heart, but AS is open source.
We are in the process of doing some refactorings that will allow us to optionally swap Compose for Desktop in lieu of LayoutLib, but that work is still in the early stages.