ListView landscape/portrait

gspanu

Member
Licensed User
Longtime User
This code populate a listview( from ListView example).

'-------------------------------------------------------------------
ListView1.Initialize("ListView1")
Dim GD As GradientDrawable
GD.Initialize("TR_BL", Array As Int(Colors.Gray, Colors.LightGray))
Activity.Background = GD
ListView1.ScrollingBackgroundColor = Colors.Transparent
Dim Bitmap1 As Bitmap
Bitmap1.Initialize(File.DirAssets, "button.gif")

ListView1.SingleLineLayout.ItemHeight = 100dip
ListView1.SingleLineLayout.Label.TextSize = 20
ListView1.SingleLineLayout.Label.TextColor = Colors.Blue
ListView1.SingleLineLayout.Label.Gravity = Gravity.CENTER
ListView1.FastScrollEnabled = True

For i = 1 To 500
ListView1.AddSingleLine("Item #" & i & "
12345678901234567890123456789012345678901234567890")
ListView1.AddTwoLines( "Item #" & i & "
12345678901234567890123456789012345678901234567890" , "This is the second
line.")
ListView1.AddTwoLinesAndBitmap("Item #" & i & "
12345678901234567890123456789012345678901234567890" , "This is the second
line with bmp.", Bitmap1)
Next
Activity.AddView( ListView1, 0, 0, 100%x, 100%y)

'-------------------------------------------------------------------

The display in landscape format ( fig.1.jpg) is correct but not in portrait
format ( fig.2.jpb).

Can you help me?
 

Attachments

  • 1.jpg
    1.jpg
    67.9 KB · Views: 323
  • 2.jpg
    2.jpg
    73.7 KB · Views: 291

klaus

Expert
Licensed User
Longtime User
What do expect in portrait?
The two screenshots show what you have coded.
Are you shure you want the text in the SingleLine items centered ?
The width in landscape is wider than the text so it is dispalyed in one line.
The width in portrait is smaller than the text so it is displayed in multiline with a line feed at black characters if there are some.

Best regards.
 

gspanu

Member
Licensed User
Longtime User
The problem in portrait is in the "TwoLine" item, the first label is not correctly displayed as in "OneLine"

Best regards.
 

klaus

Expert
Licensed User
Longtime User
You must also define the layout for TwoLinesLayout and TwoLinesLayoutBitmap!
If you look carefully at the portrait screenshot you see that there is some very small text on top of the twoline items.
That means that the height of the first label is not heigh enough and also the gravity is not the same as in the SingleLineLayout.
Defining a layout for the SingleLineLayout has no effect on the two other layouts, so if you use all three possibilities you must define a layout for each one.

Best regards.
 
Top