Skip to content Skip to sidebar Skip to footer

How To Use Custom Imageview

I have found the following code on how to get display height and width from ImageView: Trying to get the display size of an image in an ImageView . When I try to use it in the layo

Solution 1:

Make sure you have provided the right constructor for the XML. Your custom Views constructor should have the following method signature:

publicSizeAwareImageView(Context context, AttributeSet attrs){
  // todo
}

I'm guessing it currently looks like this:

publicSizeAwareImageView(Context context){
  // todo
}

Also I'd double check you meant to set the XML parameter android:background, for ImageView you actually set android:src.

Post a Comment for "How To Use Custom Imageview"