Android Question UltimateListView, different sizes of images

schimanski

Well-Known Member
Licensed User
Longtime User
Hello!

With the following code, I'm loading images into an ultimatelitview. That runs very fine...

My problem is, that every image has a different size. It seems, that the resolution of the images make the different. Is it possible to keep the proportion and adapt the size in the ulv?

Thanks for help....

B4X:
Sub Bild_AddLayoutAndItem(SentMsg As Boolean, MsgID As Int)
    Dim su As StringUtils
    Dim MsgHeight As Int = Max(30dip, su.MeasureMultilineTextHeight(lblMeasure, Messages.Get(MsgID))) + VerticalPadding

    Dim LayoutName As String
    If SentMsg Then
        LayoutName = "Sent" & MsgHeight
    Else
        LayoutName = "Received" & MsgHeight
    End If
    If Not(ULV.LayoutExists(LayoutName)) Then
        ULV.AddLayout(LayoutName, "Bild_LayoutCreator", "Bild_ContentFiller", 275dip, True)
    End If
    ULV.AddItem(LayoutName, MsgID)
End Sub

Sub Bild_LayoutCreator(LayoutName As String, LayoutPanel As Panel)
    Dim lblText, lblZeit As Label
    Dim iv1 As ImageView
    lblText.Initialize("")
    iv1.Initialize("")
    lblZeit.Initialize("")
    iv1.Gravity=Gravity.NO_GRAVITY
    If LayoutName.StartsWith("SENT") Then
        lblText.Background = LoadNinePatchDrawable("balloon_left")
    Else
        lblText.Background = LoadNinePatchDrawable("balloon_right")
    End If
    If LayoutName.StartsWith("SENT") Then
        LayoutPanel.AddView(lblText, 15%x, 0, 85%x, LayoutPanel.Height)
        LayoutPanel.AddView(iv1, 20%x, 10dip, 200dip, 200dip)
        LayoutPanel.AddView(lblZeit, 15%x, LayoutPanel.Height-25dip, 80%x, 15dip)
    Else
        LayoutPanel.AddView(lblText, 0, 0, 85%x, LayoutPanel.Height)
        LayoutPanel.AddView(iv1, 10%x, 35dip, 200dip, 200dip)
        LayoutPanel.AddView(lblZeit, 0, LayoutPanel.Height-25dip, 80%x, 15dip)
    End If
End Sub

Sub Bild_ContentFiller(ItemID As Long, LayoutName As String, LayoutPanel As Panel, Position As Int)
    Dim lblText As Label = LayoutPanel.GetView(0)
    lblText.Text = Messages.Get(ItemID)
    Dim iv1 As ImageView = LayoutPanel.GetView(1)
    If File.Exists(File.DirRootExternal, Dokument.Name)=True Then
        ULV.LoadImageAsync(iv1, "/mnt/sdcard/" & Dokument.Name, ItemID)
    Else
        iv1.Bitmap=kamera_icon
    End If
    Dim lblZeit As Label =LayoutPanel.GetView(2)
    lblZeit.Text = "test"
End Sub
 
Top