Android Question ImageView ScaleType

socialnetis

Active Member
Licensed User
Longtime User
Hi, I'm using this piece of code to change the ScaleType of an ImageVIew:

B4X:
Sub SetScaleType(i As ImageView,ScaleType As String)
    Dim r As Reflector
    r.Target = i
    r.RunMethod2("setScaleType",ScaleType,"android.widget.ImageView$ScaleType")
    Log(r.RunMethod("getScaleType"))
End Sub

The Log shows that the ScaleType is the one I set, however I can't see any effect in the ImageView (I tried with CENTER_INSIDE and CENTER_CROP).

What am I missing?
 

socialnetis

Active Member
Licensed User
Longtime User
Ok, after using ICOSImageview which exposes this method, and seeing that they work, I realized that the common ImageView' bitmap property, is actually for the background.

Shouldn't this be fixed? For example, if someone wants to use a padding in the imageview (lets say for a picture frame), and red background color (for the frame's color) and then set the bitmap, they will actually override the full ImageView background, and not the container of the ImageView.

I know that there is always a workarround (for example using the imageview in front of a panel, and use the panel as the frame), but maybe the bitmap property should be the correct one, to explode all the potencial using the reflection library.
 
Upvote 0
Top