Android Question ListViewTwoColumns problem with right-adjusted item

clooney48

Active Member
Licensed User
Longtime User
Hello!

Is it not possible to set the item in the second column right-adjusted AND vertical-centered? I tried it this way. It is right-adjusted but no more vertical-centered.

B4X:
Sub Globals
    Dim lsvTest As ListView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    lsvTest.Initialize("lsvTest")
    Activity.AddView(lsvTest, 0, 0, 100%x, 100%y)
    lsvTest.TwoLinesLayout.ItemHeight = 40dip
    lsvTest.TwoLinesLayout.Label.Top = 0
    lsvTest.TwoLinesLayout.Label.Left = 0
    lsvTest.TwoLinesLayout.Label.Width = 50%x
    lsvTest.TwoLinesLayout.Label.Height = 40dip
    lsvTest.TwoLinesLayout.Label.Gravity = Gravity.CENTER_VERTICAL
    lsvTest.TwoLinesLayout.Label.Color = Colors.Red
    lsvTest.TwoLinesLayout.Label.TextSize = 18
   
    lsvTest.TwoLinesLayout.SecondLabel.Top = 0
    lsvTest.TwoLinesLayout.SecondLabel.Left = 50%x
    lsvTest.TwoLinesLayout.SecondLabel.Width = 50%x
    lsvTest.TwoLinesLayout.SecondLabel.Height = 40dip
    lsvTest.TwoLinesLayout.SecondLabel.Gravity = Gravity.RIGHT
    lsvTest.TwoLinesLayout.SecondLabel.Gravity = Gravity.CENTER_VERTICAL '>>Doesn´t work with Gravity.RIGHT
    lsvTest.TwoLinesLayout.SecondLabel.Color = Colors.Blue
    lsvTest.TwoLinesLayout.SecondLabel.TextColor = Colors.Yellow
    lsvTest.TwoLinesLayout.SecondLabel.TextSize = 18

    For i = 0 To 100
        lsvTest.AddTwoLines("Test1" & i, "Test2" & i)
    Next
End Sub
 

clooney48

Active Member
Licensed User
Longtime User
Try
lsvTest.TwoLinesLayout.SecondLabel.Gravity = Gravity.CENTER
or
lsvTest.TwoLinesLayout.SecondLabel.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.CENTER_HORIZONTAL)
Thank you, Klaus, this did the job finally:
B4X:
lsvTest.TwoLinesLayout.SecondLabel.Gravity = Bit.OR(Gravity.CENTER_VERTICAL, Gravity.RIGHT)
 
Upvote 0
Top