Android Question Buttons dimension


Active Member
Licensed User
I would create buttons "glued" togheter but buttons seem to have a transparent border around.
It is this a type of property? What is the size of the borders?
John Rossati


Licensed User
Depending on how you plan to use them, you might be better off using panels. These occupy the full area per their width and height and, like buttons, have Click and LongClick events.

If you are implementing a touch-sensitive overlay upon an image (map? photo of remote control? sudoku game panel?) then you can make the panels transparent, yet they still respond to clicks etc.

Edit: panels also have a Touch event that tells you which part of the panel was touched. This even is called for each touch-down, touch-move and touch-up.
Last edited:


Licensed User
If you change the background from DefaultDrawable to any other, the button extends to the total size.
The four upper buttons, default background.
The four lower buttons, ColorDrawable with border, GradientDrawable, BitmapDrawable and ColorDrawable without border.
Be aware that buttons use the StatelistDrawable with different backgrounds for the different states.


Attached the demo program.

As emexes already suggested, Panels are also a solution.
I use Panels instead of Buttons quite often in my programs.



Active Member
Licensed User
Thanks Emexes and Klaus
your answers not only have they been clarifying, but they have also increased my (poor) knowledge of B4x and Java.
Jean Rossati