Android Question Keep text out of the alignment of the CustomListView tool

AlfaizDev

Well-Known Member
Licensed User
Hi
I am using the CustomListView class
The text in this tool is spread to the parties
I want to keep it from the edges a little
look at the picture
In ListView1 I used this code to do that

B4X:
ListView1.SingleLineLayout.Label.Width=ListView1.Width-20dip

So what code should I use now?
See problem in the picture

thank you
 

Attachments

  • CustomListView.png
    CustomListView.png
    328.8 KB · Views: 173

Mahares

Expert
Licensed User
Longtime User
You are NOT using CustomListView but ListView (which I do not recommend).
I am pretty sure he is using a customlistview class. He was showing you how he did it when he was using listview.
As you recommended he needs to switch to the latest CustomListView library and remove the class module.
I want to keep it from the edges a little
So what code should I use now?
See problem in the picture
I assume you are using the Designer for the CustomListView. If so, did you see the 'Padding' property for the customlistview?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Using CustomListView class is a mistake. You should use xCustomListView library.

You can change the padding of text items with:
B4X:
For i = 0 To clv1.Size - 1
    Dim pnl As B4XView = clv1.GetPanel(i)
    If pnl.GetView(0) Is Label Then
        Dim lbl As Label = pnl.GetView(0)
        lbl.Padding = Array As Int(10dip, 0, 10dip, 0)
    End If
Next
Run this code after you added the items.
 
Upvote 0

AlfaizDev

Well-Known Member
Licensed User
Thanks to all
Using CustomListView class is a mistake. You should use xCustomListView library.

I am using the CustomListView class
Because I made some adjustments to it

You can change the padding of text items with:
B4X:
For i = 0 To clv1.Size - 1
    Dim pnl As B4XView = clv1.GetPanel(i)
    If pnl.GetView(0) Is Label Then
        Dim lbl As Label = pnl.GetView(0)
        lbl.Padding = Array As Int(10dip, 0, 10dip, 0)
    End If
Next
Run this code after you added the items.

It works well
Thank you
Erel

How to make text alignment =justify
if that's possible
 
Upvote 0

AlfaizDev

Well-Known Member
Licensed User
99.99% that it was not needed. Which changes have you made?

Things in shape
for example
this is
Hired
lbl.SetBackgroundImage (SetBackgroundImage)
Controls the image, so that the image appears complete throughout
Row

And also this one
lbl.Typeface = MyFont
Specifies the type of font

This is to make the alignment of the text = justify
lbl.Gravity = Bit.Or (Gravity.CENTER, Gravity.FILL)
But it did not work
And maybe others
 
Upvote 0

AlfaizDev

Well-Known Member
Licensed User
I could not do it through the callback
as I want
So it worked


And also another matter
It is when I use the class elsewhere
Be ready
As I want

In the end, each one has his own way
And the novice is not like a professional
I am still new
 
Upvote 0

AlfaizDev

Well-Known Member
Licensed User
We always benefit from you
Professionals

See the code that you sent me since I use the CustomListView class
I just added this part.
B4X:
lbl.Padding = Array As Int (10dip, 0, 10dip, 0)
in a
B4X:
Private Sub CreateLabel (txt As Object) As B4XView
-------
Return lbl
End Sub

It works
This is what I like about the class
I like to play around with it

thank you very much
Erel
 
Upvote 0
Top