Android Question Designer - minimum layout height - B4A 5.80

LucaMs

Expert
Licensed User
Longtime User
I tried to create a layout 40dip height.
I received this message:
upload_2016-3-28_11-56-38.png


('-10' is not a valid value for property "Height").


You don't see the new variant in the list, but if you save and open again the Designer, you can see it, but you get the same message.

Also, after I created a layout 50dip; the gray panel does not appear (Designer) and, unless I do something was wrong (dimensions), loading the layout is incorrect (attached project).


Thank you
 

Attachments

  • CLV Test.zip
    10.9 KB · Views: 159
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Also, after I created a layout 50dip; the gray panel does not appear (Designer) and, unless I do something was wrong (dimensions), loading the layout is incorrect (attached project).

It is "right". My error is:
B4X:
CustomListView1.Add(CreateHeader(210dip, 50dip), 50dip, 0)

the header layout is 210dip x 50dip but scaled; the height of the buttons results 93dip on my device (this is why I want to create a 40dip height layout).

So, I don't know an easy way to manage this situations.

Anyway, this is not the "question" of this thread.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
The layout width and height are always determined by the parent. So you must explicitly set them yourself.
:eek:

As you can see the look is bad (I would have to post the landscape phone screenshot)
upload_2016-3-28_16-49-7.png



How can I get (in your example) items having the same look (proportions, distances from edges)? Using percentages?
[Please, start a new thread for this question :) or should I post it there?]
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
How can I get (in your example) items having the same look (proportions, distances from edges)? Using percentages?

Solved :)

Tablet:
upload_2016-3-28_17-42-17.png



Phone:
upload_2016-3-28_17-43-27.png




Main change:
B4X:
Sub CreateListItem(ToGetItemHeight As Boolean, Text As String, Width As Int, Height As Int) As Panel
    Dim p As Panel
    p.Initialize("")
    If ToGetItemHeight Then
        'we need to add the panel to a parent. It will be removed after the layout is loaded.
        Activity.AddView(p, 0, 0, 0, 0)
        p.LoadLayout("CellItem")
        mCLV2ItemHeight = Button1.Height
    Else
        'we need to add the panel to a parent to set its dimensions. It will be removed after the layout is loaded.
        Activity.AddView(p, 0, 0, Width, Height)
        p.LoadLayout("CellItem")
    End If
    p.RemoveView
    'label1 and button1 will point to the last added views.
    Label1.Text = Text
    Button1.Text = "Click"
    Return p
End Sub
 

Attachments

  • CustomListView Example.zip
    11.1 KB · Views: 182
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
In this way it is "more correct".
B4X:
Sub CreateListItem(ToGetItemHeight As Boolean, Text As String, Width As Int, Height As Int) As Panel
    Dim p As Panel
    p.Initialize("")
    If ToGetItemHeight Then
        Activity.AddView(p, 0, 0, 0, 0)
        p.LoadLayout("CellItem")
        mCLV2ItemHeight = Button1.Height
    Else
        'we need to add the panel to a parent to set its dimensions. It will be removed after the layout is loaded.
        Activity.AddView(p, 0, 0, Width, Height)
        p.LoadLayout("CellItem")
        'label1 and button1 will point to the last added views.
        Label1.Text = Text
        Button1.Text = "Click"
    End If
    p.RemoveView
    Return p
End Sub
 
Upvote 0
Top