Android Question How to present an image in an imageview without loss of proportion

vecino

Well-Known Member
Licensed User
Longtime User
Hi, I need to display many images of different sizes, but the imageview has a fixed size chosen by the user.
All images are large, but the imageview is small.
It is similar to a catalog.
The problem is that they must be displayed whole, and without losing proportion.
What do you advise me?
Thank you.

In this case I have scaled them to a fixed size, but the user will be able to change the size of each item, bigger or smaller, and what I want is that the images are always displayed well, whatever the size of the imageview.
66c966f3ba121bad14059bc1d1fea619-3889585295.png
 
Last edited:

vecino

Well-Known Member
Licensed User
Longtime User
I don't know if I'm wrong, but I think I read in some thread that you can't add at runtime a b4ximageview to a panel. or did I dream it?
I mean I thought you couldn't do something like that:
B4X:
dim p as panel
p.initialize("p")
p. ...
dim iv as b4ximageview
iv.initialize(null, "iv")
p.addview(iv, ... )
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Thanks, I did not know XUIViewsUtils.
What about adding the view to a panel?
B4X:
Dim p As Panel
p.Initialize("p")
Dim iv As B4XImageView = XUIViewsUtils.CreateB4XImageView
p.AddView(iv,0,0,p.Width,p.Height)  ' <-- Types do not match. (warning #22)

src\conkex\preventa\acventas.java:16815: error: incompatible types: b4ximageview cannot be converted to View
_p.AddView((android.view.View)(_ivimgarti),(int) (0),(int) (0),(int) (_p.getWidth()),(int) (_p.getHeight()-anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (0))));
Completed. Exit code: 1
 
Upvote 0
Top