Android Question How clear gaps between the button and the button.

Jones Hone

Active Member
Licensed User
Longtime User
I want no spacing between button and button on runtime.
How should I do it? Thank you!



 

Jones Hone

Active Member
Licensed User
Longtime User
Button1.Left=10dip
Button1.Width=100dip
Button2.Left=110dip
Button2.Width=100dip

I think: Button2.Left=Button1.Left+Button1.Width=110dip
If I change: Button2.Left=102dip There will be no gap.
Thank you very much!
Is there a better way?
 
Upvote 0

Jones Hone

Active Member
Licensed User
Longtime User
Hi Erel, I've tested that thread,But it set padding only, not set the gap between button and button.
but,That is also I need.
Anyway,Thank you very much.
 
Upvote 0

Jones Hone

Active Member
Licensed User
Longtime User
I'm not use layout! I created button by code.
attached file is my test project. Can you help me.
Thank you!
 

Attachments

  • MyButtonTestProject.zip
    285 KB · Views: 243
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please use File - Export as zip when uploading projects.

The problem is not with the padding. I was wrong ,the padding is not relevant here.
The buttons default drawable includes a small gap. If you replace it by replacing the background then there is no gap:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   For x = 0 To 10
     For y = 0 To 10
       Dim b As Button
       b.Initialize("b")
       b.Text = x & " " & y
       b.Color = Colors.Blue
       Activity.AddView(b, 40dip * x, 40dip * y, 40dip, 40dip)
     Next
   Next
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…