Hi Everyone. I am stuck with a project for more than one week and i really can't figure out a solution.
What i've been trying to do is: 1) Create a Custom View (OK) 2) Override the method onDraw and then do something with the canvas (Ok) 3) Add the CustomView to the activity_main.xml - so it will be acessible from MainActivity 4) On the MainAcvitiy, convert this custom view to a bitmap“(here starts the problems ) I've tried several methods but i can't convert my View to bitmap. Whenever i try to access its contents or properties, its like the object is null (because width and height are 0). People told me i should access this view from an ViewTreeObserver.doOnGloballayout but the results were the same. When i try to toast the View width\height, it shows 0 for both. Any input is appreciated. activity_main.xml https://pastebin.com/gj77Caqk ViewTreeObserver.doOnGlobalLayout Extension method https://pastebin.com/1pdKyVy6 CustomView.kt https://pastebin.com/ScWM58SE MainActivity.kt https://pastebin.com/71cefUUj Extension method for converting a view to BitMap https://pastebin.com/ivFSPezB -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/29434eac-9cff-48aa-a39e-16677111cb55%40googlegroups.com.

