I am using Eclipse to write an Android app that has a column of buttons, and when one is pressed it will open another column of buttons next to it that corresponds to the button pressed.
What I would like to do is add a solid line that connects the button pressed to the new column so visually it can be 开发者_开发技巧seen which button the new column relates too (not worried about the vertical relationship) e.g.
[B1] [B5]
[B2]---[B6]
[B3] [B7]
[B4]
I had a look at the "How to draw a line in android" post, but I was wondering if it would work in my case as I'm using Relative Layout? Thinking that if the app was to change devices (namely screen size) would the line then be misplaced with respect to the buttons.
I could be wrong as I'm very new to Android and Java but thought it worth asking.
One way I was thinking may work, if it's possible, would be to somehow have the line connected/linked to the buttons???
Thank you,
Markus
I would use a vertical LinearLayout (or RelativeLayout) for each column and instead of just one button per row, I would use an horizontal LinearLayout with both the button and the line per row, like so:
[B1, L1][B5]
[B2, L2][B6]
[B3, L3][B7]
[B4, L4]
The line view would only be visible in the selected row. The line view could be any transparent view (ImageView, LinearLayout, RelativeLayout, FrameLayout, etc...) with a background set to a Drawable (the line). The drawable can be created programmatically or loaded from a resource.
Assuming you're doing something in the likes of hierarchical tabs, consider using toggle buttons.
精彩评论