Android Question customlistview setlayoutanimated

Discussion in 'Android Questions' started by Kiran Raotole, Aug 18, 2018.

  1. Kiran Raotole

    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.
     
  2. Erel

    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.
     
  3. Kiran Raotole

    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
     
  4. Erel

    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.
     
  5. MarkusR

    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.

    Code:
    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
     
  6. Kiran Raotole

    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
     

    Attached Files:

  7. Erel

    Erel Administrator Staff Member Licensed User

    This is not needed:
    Code:
    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:
    Code:
    p.SetLayoutAnimated(000, clv1.AsView.Width, 30dip)
     
  8. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    can i also use this like :
    Code:
    p.SetLayoutAnimated(000, clv1.AsView.Width, clv1.AsView.Height)
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    Yes. If you want each item height to be the same as the list height.
     
  10. Kiran Raotole

    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
     
  11. MarkusR

    MarkusR Well-Known Member Licensed User

    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.
     
  12. Erel

    Erel Administrator Staff Member Licensed User

    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.
     
  13. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    I have a panel in that layout, i used :
    Code:
    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.
     
  14. Erel

    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:
    Code:
    p.SetLayoutAnimated(000, clv.AsView.Width, 237dip)
    p.LoadLayout(...)
     
  15. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    Ok its helpful. I'm thinking for direct command without entering manual value.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice