1

I am new in android, want to show border in tablelayout.

can any one please help me, it is very critical for me.

user680530
  • 11
  • 1
  • 3

1 Answers1

5

Try setting a ShapeDrawable as the background of the elements you want a border on. You can define a ShapeDrawable in an XML file in your res/drawables folder. In particular, the stroke element has the dashWidth and dashGaps parameters that let you make a dashed line:

<stroke
    android:width="integer"
    android:color="color"
    android:dashWidth="integer"
    android:dashGap="integer" />

You can also just set a repeating dots image as the background of the entire table, then set a solid background and margin on the cells (see this trick, which is written about solid borders but I'm sure you can fake with a 2x2 repeating bitmap of a checkerboard pattern).

Community
  • 1
  • 1
Yoni Samlan
  • 37,905
  • 5
  • 60
  • 62
  • I have implemented shape with button ... but i am not able to show border in table layout 1) coupon_detail_table i don't know why it is not working – user680530 Mar 30 '11 at 12:13
  • You can't just jam the shape drawable in the layout file - you need to define it in its own XML file in the drawables folder, then set that drawable as the `android:background` of the View in the layout that you want. See the Graphics/Drawables demos and related XML files in the ApiDemos app to get a feel for how that works (http://developer.android.com/resources/samples/ApiDemos/index.html) – Yoni Samlan Mar 30 '11 at 14:49