Android Question Buttons dimension

rossati

Active Member
Licensed User
Hi
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?
Thanks
John Rossati
 

emexes

Well-Known Member
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:

klaus

Expert
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.

upload_2019-8-6_13-32-28.png


Attached the demo program.

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

Attachments

rossati

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
 
Top