Android Question custom controls problems

Roberto P.

Well-Known Member
Licensed User
Longtime User
Hello to all
I created a custom control that can not handle the Horizzontal anchor position and does not display the entered text in control.
In practice, the custom control I can not set the properties.

where am I wrong?

I enclose the sample project.
Thank you
 

Attachments

  • testcontrols.zip
    8.8 KB · Views: 114

klaus

Expert
Licensed User
Longtime User
The first problem is the textcolor.
The default color of a Label doesn't work with EditText. I added a standard Label you'll see the color.
You should not use Lbl.Width. With Anchors the value is OK. But without Anchors Lbl.Width = 0.
For a CustomView the position and dimensions are defined by the Base panel.
The text properties are defined in the Lbl label.
I added a Text property to your CustomView, that way it works like the other views.

Attached the modified project.

You may have a look at the B4A User's Guide.
CustomViews are explained in detail.
 

Attachments

  • testcontrols1.zip
    9 KB · Views: 123
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
Hello Klaus
thanks for your answer.

But they have not solved the problems or something wrong again.
The controls (base) are not positioned as a set in designer. If you look at the two control it does not have the width and distance from the right edge that I have set.

I purposely disabled the edit control to understand how it behaves.

Can someone help me understand this strange behavior.

Thanks so much
Greetings
 

Attachments

  • test2.zip
    9 KB · Views: 124
Upvote 0

klaus

Expert
Licensed User
Longtime User
The problem in your layout is the following:
You set anchors in Panel1.
Then you set Panel1.Width = 100% in the Designer.
But the Designer overwrites the Anchors, which means that the Anchors dont follow.
If you set the horizontal anchor of Panel1 to BOTH you get the behaviour you expect.
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
The problem in your layout is the following:
You set anchors in Panel1.
Then you set Panel1.Width = 100% in the Designer.
But the Designer overwrites the Anchors, which means that the Anchors dont follow.
If you set the horizontal anchor of Panel1 to BOTH you get the behaviour you expect.
Thanks Klaus
 
Upvote 0
Top