I have a series of ImageButtons horizontally laid out in a LinearLayout. When I do a setBackgroundColor to GREEN, these ImageButtons all become GREEN rectangles, all connected that look like one single bar. Is there a way I can specify a border between these buttons, so I know where one button starts and where it ends?
For making the gap between two buttons by displaying Separator (something like Horizontal line)
, you have to Add Blank View
in between two buttons.
Thereby inserting a blank view creates a line separator. This separator view is used to separate the area below the buttons and above buttons:
<View
android:layout_height="2px"
android:background="#DDFFDD"
android:layout_marginTop="5dip"
android:layout_marginBottom="5dip"/>
Try it.
Enjoy!!
when i make a button transparent, then i dont really see, when i click a button... have you any idea how i can do, that the button has a click effect?
A blank View will bloat your Layout. There are two distinct concepts in the Android Layout one is the padding
. Padding will be added to the width of the layout and it defines how much space is free from the boarder of the view to the content of the view. The backgroundcolor is behind the whole View therefore the whole area inclusive the padding is filled with the backgroundColor.
The second concept is layout_margin
layout margin is the space that is used from the visible boarder of the view to another boarder. A View can not draw itself into the margin space.
Giving the button the attribute layout_margin should help you to have a visible space between the buttons without adding another view for each pair of buttons.