Gridlayout with borders
Asked Answered
S

1

6

I'm a new Android developer, and I'm just trying to improve my skill by reading some samples, I want to design a new interface using GridLayout, I've checked a lot of samples but I can't seem to draw borders between the GridLayout cells. What could I be missing?

Here is a link that I went through it, but the borders didn't show up!

http://developer.samsung.com/android/technical-docs/GridLayout-in-Android#

I appreciate your care in advance.

Sabellian answered 8/12, 2012 at 10:18 Comment(0)
H
3

Android Layout containers don't draw borders. Still:

  1. You can set background of each cell's View to an xml Drawable resource, which describes a transparent rectangle with borders.

  2. Give a background color to GridView's parent View, and set each GridView cell View's background to a different color.

Both of these can also be applied as a Style.

Hyperextension answered 8/12, 2012 at 11:33 Comment(2)
Thanks a lot,it worked,but is there a way to recognize the size of the image which i set as the background!?or it doesn't differ for different cells with different content size!?Sabellian
@SohaSoha The Shapes defined in XML Drawable auto stretch by default. If you use a PNG image, make it 9-patch, it will then scale nicely to whatever size it has to fit. 9-patch tools is provided in android SDK.Hyperextension

© 2022 - 2024 — McMap. All rights reserved.