Kulwinder Singh
08/28/2019, 11:34 AMConstraintLayout
-:
class CustomView(context: Context, attrs: AttributeSet) : ConstraintLayout(context, attrs) {
init {
var a: TypedArray? = null
......
val backgroundImage = a.getResourceId(R.styleable.CustomView_backgroundImage, -0)// image will be from assets
inflate(context, R.layout.custom_view, this)
if (backgroundImage != -0) Picasso.get().load(backgroundImage).into(img_background)
.....
}
}
with this code app compiles and on device it loads image. but problem is that it don't show image preview on android studio and android studio unable to render layout. any solution to this ?wasyl
08/28/2019, 11:36 AMView#isInEditMode
to specify logic for the preview. Since in preview Picasso doesn’t work, it should be fine if you load the image directly thenKulwinder Singh
08/28/2019, 11:39 AMView#isInEditMode
will work, thanks a lot @wasyl, also is my approach loading image inside custom view's constructor using Picasso good ? or there any bad point in this ?wasyl
08/28/2019, 11:40 AMisInEditMode
for such subclass, I thinkKulwinder Singh
08/28/2019, 11:43 AMisInEditMode
worked 👍res/drawable/*
folder in this view, don't know if it is efficient using picasso ? can you please let me know about it ? because upto now i was using this view without picasso and don't got any Memory exceptionwasyl
08/28/2019, 12:33 PMKulwinder Singh
08/28/2019, 1:01 PM