Android Question Button Text

peggjones

Active Member
Licensed User
Longtime User
When I execute the following code

Dim buttonadd As Button
buttonadd.Initialize("buttonadd")
buttonadd.Text="Add New"
buttonadd.TextColor=Colors.Black
buttonadd.TextSize=18
Activity.AddView(buttonadd, 0, 92%y, 250, 120%y)

I can see the button but not the text.

Anyone tell me why?

Thanks
 

klaus

Expert
Licensed User
Longtime User
Activity.AddView(buttonadd, 0, 92%y, 250, 120%y)
This is strange ?
The Top property is 92%y and the Height property is 120%y bigger than the screen size.
This means with a screen height of 800 pixels.
Top = 735 pixels and the height is 960 pixels so the bottom is at 1695 pixels.
The biggest part of the Button is out of the screen and of cours you won't see any text !!!

Best regards.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please use [ code ] [ /code ] tags (without spaces) when posting code.

You are not adding the view correctly:
1. There should be a warning about 250. You need to change it to 250dip.
2. You've set the button height to 120%y. This means that the button height is 1.2 * Activity.Height. This is not what you intended.

I recommend you to set the layout with the visual designer + designer script.
 
Upvote 0
Top