Android Question customlistview setlayoutanimated

Kiran Raotole

Active Member
Licensed User
Hii Expert

I designing CustomListView in my app.
I need it five different times and in five different look with other layout

I have issue with p.SetLayoutAnimated(0,0,0,60%x,35%x)

I am confuse about how to give width and height,
so is their is any way to get panel used height

also if i'm giving height width manually ,
it change in different resolution mobile.

Thanks in advance.
 

Erel

Administrator
Staff member
Licensed User
1. Make sure to use xCustomListView.
2. You should add them with the designer and use anchors or designer script to set their layout.
 

Kiran Raotole

Active Member
Licensed User
I'm creating it with designer and I have issue on setting height and width for that listview row
I used this command :
p.SetLayoutAnimated(0,0,0,60%x,35%x)

But i'm unable to found exact height and width of that designer / view
 

Erel

Administrator
Staff member
Licensed User
I don't understand anything.

Where is the code that creates the items? Note that it should be 35%y instead of %x.
 

MarkusR

Well-Known Member
Licensed User
you can see the height in the designer, i think u do not want use %y
dip give u the same size at any device.

B4X:
Sub CreateListItem(Item As SinglePassword) As B4XView
    
    Dim p As B4XView = xui.CreatePanel("Row")
    #if B4J
        p.SetLayoutAnimated(0 ,0,0,600,30dip) 'how to use 100%x ???
    #Else If B4A
        p.SetLayoutAnimated(0 ,0,0,100%x,30dip)
    #End If
    p.LoadLayout("Row")
    
    LabelColumn1.Text = Item.Name
    LabelColumn2.Text = Item.User
    LabelColumn3.Text = Item.Mail
    LabelColumn4.Text = Item.Url
    
    Return p
    
End Sub
 

Kiran Raotole

Active Member
Licensed User
I want correct percent of x,y to work in any handset properly according to layout

screen shot of my layout

I want exact row height and widht
in my image height is more than and horizontal anchor is not proper
 

Attachments

Erel

Administrator
Staff member
Licensed User
This is not needed:
B4X:
  Dim p As B4XView = xui.CreatePanel("Row")
    #if B4J
        p.SetLayoutAnimated(0 ,0,0,600,30dip) 'how to use 100%x ???
    #Else If B4A
        p.SetLayoutAnimated(0 ,0,0,100%x,30dip)
    #End If
It should be:
B4X:
p.SetLayoutAnimated(0, 0, 0, clv1.AsView.Width, 30dip)
 

Erel

Administrator
Staff member
Licensed User
Yes. If you want each item height to be the same as the list height.
 

Kiran Raotole

Active Member
Licensed User
No. I want actually used height from top of my that layout designer file,
like my custom listview designer has three label, then I need height upto three label.
Is any command there that give me actual used height
 

MarkusR

Well-Known Member
Licensed User
my custom listview designer has three label, then I need height upto three label.
u can use .top .height property from labels or the variant size you set in the designer.
for a static layout i would drag one element into, size as needed and copy/paste this height.

in your case at static layout the top+height of the last label is your row height.
 

Erel

Administrator
Staff member
Licensed User
in your case at static layout the top+height of the last label is your row height.
That's true. You need to check the height required and set it.

As a general rule, the layout size is always set by its parent container.
 

Kiran Raotole

Active Member
Licensed User
I have a panel in that layout, i used :
B4X:
    Dim p As B4XView = xui.CreatePanel("")
   p.LoadLayout("m411_listview")
   p.SetLayoutAnimated(0,0,0,100%x,panel1.height)
But it show nothing. also give log Panel size is unknown. Layout may not be loaded correctly.
 

Erel

Administrator
Staff member
Licensed User
1. You should never load a layout to a panel before the panel size is set.
2. As a general rule, the layout size is always set by its parent container.

Open the m411_listview layout file and calculate its size.

Then set it with:
B4X:
p.SetLayoutAnimated(0, 0, 0, clv.AsView.Width, 237dip)
p.LoadLayout(...)
 
Top