Android Question ListView Height not same on different android box?

ronovar

Active Member
Licensed User
Longtime User
I have used ListView with AddTwoLinesAndBitmap2 and this works fine...now i get into problem that ListView Height is not same on all devices...i try to use xml layout for listview but i get error in B4A when i try to use AddTwoLinesAndBitmap2.

I define ListView this way:

B4X:
'GET - Panels
pnlVideoClubList = Xml.GetView("pnlVideoClubList")

'ADDVIEW - lvVideoClubList
pnlVideoClubList.AddView(lvVideoClubList, 0, 0, pnlVideoClubList.Width, pnlVideoClubList.Height)

And pnlVideoClubList is defined in XML this way:

B4X:
<RelativeLayout
        android:id="@+id/VideoClubList"
        android:layout_width="598dp"
        android:layout_height="532dp"
        android:layout_centerVertical="true"
        android:layout_marginLeft="73dp" >
   
        <Panel
            android:id="@+id/pnlVideoClubList"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
     </RelativeLayout>

So i have 14 items witch one item height is 38dip so 14 items x 38dip = 532dp and on one android box (MyGica) ListView is correct and on other android box (MX III) ListView is showing 14 items and one half item.... how to fill listview to panel pnlVideoClubList so that ListView will be same on all devices?

Or any other idea?
 

ronovar

Active Member
Licensed User
Longtime User
Thanks..for solution i try it and on seconde android box there is visible 14items and half...so solution does not work.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
If you want "same size" (fixed size) of ListView and ListView Items on all devices you must set their size in dip (so your ListView can be 3cm height on all devices, for example).
If you want they have the same proportions you must use percentages (lvVideoClub.Height = 75%y)
 
Upvote 0

ronovar

Active Member
Licensed User
Longtime User
I wil try with width and height for example 40%x and 80%y and replay results... strange is that i could not use in B4A xml defined width and height like parent_fill (inside panel) so that way will listview expand to panel size....
 
Upvote 0
Top