Without looking into your code, it's hard to say what could be causing the performance issue. But I see you display image in view pager. Creating bitmap is CPU and memory intensive task. I guess when you open the ViewPager
, the keyboard opens up at the same time as creating bitmap. Try to disable the keyboard on first activity start. Only start when EditText
gains focus and also try to cache created Bitmaps
to some extent to save some CPU cycles. Here is the official guide for this.. While loading bitmaps, we also need to care the size of the Bitmap
we are loading in memory as compared to the ImageView
size. If we load large bitmap than the ImageView
's bound, definitely it is waste of resources. See Loading Large Bitmaps Efficiently. It is always advisable to use any image loading library to do all the heavy lifting. Here is one such library I've been using Glide
For leaving the white background, check the ViewPager
height is match-parent
or match-constraint
. I also had a problem similar to this in RecyclerView
, I solved this as mentioned here RecyclerView drawing offscreen
val obs = pager?.viewTreeObserver
obs?.addOnGlobalLayoutListener {
recyclerView?.requestLayout()
recyclerView?.invalidate()
}