0

I've attached some sample code with the issue. I create a listview with two lines and a bitmap. I disable the second label so I have just the image and one lable. I want to center the text vertically, can't seem to figure it out!!

Sub Globals
Dim listview1 As ListView
Dim bitmap1 As Bitmap
End Sub

Sub Activity_Create(FirstTime As Boolean)

bitmap1.Initialize(File.DirAssets, "fldricon.gif")
Listview1.Initialize("listview1")
ListView1.TwoLinesLayout.Label.TextSize=18
ListView1.TwoLinesLayout.ItemHeight=60

ListView1.TwoLinesAndBitmap.SecondLabel.Visible=False
ListView1.TwoLinesAndBitmap.SecondLabel.Enabled=False
ListView1.TwoLinesAndBitmap.SecondLabel.RemoveView
Listview1.TwoLinesAndBitmap.Label.Gravity=Gravity.CENTER_VERTICAL

activity.AddView(listview1,0,0,50%x,100%y)

Listview1.AddTwoLinesAndBitmap("some string","",bitmap1)

End Sub

I've disabled the second label as you can see but the first label will not center vertically. Any and all help will be most appreciated!! Thanks

1 Answers1

0

Two tips:

  1. Use dip units when specifying screen sizes:

    ListView1.TwoLinesLayout.ItemHeight=60dip

  2. Set the label color to nonblack color to see the layout of the label. You will then see that the label doesn't changes its size when you hide the second label.

The solution is:

ListView1.TwoLinesAndBitmap.Label.Height = ListView1.TwoLinesLayout.ItemHeight
Erel
  • 1,802
  • 2
  • 15
  • 58
  • Erel; thank you, this works great. As usual, you're very speedy and thorough with your answers! (This is my 2nd "thank you", the first did not seem to show up). – dagnabitboy Oct 25 '11 at 19:01
  • Hi Erel; it took quite awhile to figure out how to "accept the answer"!!! You might want to clarify that. Or.. maybe I'm just slow! – dagnabitboy Oct 26 '11 at 21:45