Android Question Custom listview, layouts, views and resolutions

bluedude

Well-Known Member
Licensed User
Longtime User
Hi,

I'm having a hard time to get my custom listview work properly on multiple resolutions. My approach is as follows:

- having layouts with a panel and views inside the panel;
- use anchors in these views;
- adding the layouts to the custom listview with exact hight not DIP;
- scale all panels in layouts with 100%x and 100%y

I'm not getting the results i'm expecting. How can I properly scale layouts in a custom listview and also have the views in the correct place?

Should I use DIP when adding the layouts to the custom listview?

Cheers.
 

KMatle

Expert
Licensed User
Longtime User
DIP is VERY important but you may mix it with x & y.

Example: When you want to have 2 labels in a row (each exact 50% wide) then use 50%x. Take dip for the height. When you add more views depending on the position of these two labels than reference the positions to the positions.

Example:

B4X:
Lbl1.setlayout(0,0,50%x,30dip)
Lbl1.setlayout(50%x,0,50%x,30dip)

Next view (let's take a listview)

B4X:
Listv.setlayout(0,lab1.top+lbl1.height,100%x,150dip)

This will positioned under labl1 (not matter how high it is -> dip takes care about different resolutions)
 
Upvote 0
Top