2011-03-28 81 views

回答

4

嘗試設置一個ShapeDrawable作爲您想要邊框的元素的背景。您可以在res/drawables文件夾中的XML文件中定義ShapeDrawable。特別是,stroke元素具有dashWidthdashGaps參數,讓你做一個虛線:

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

您也可以只設置一個重複點的圖像作爲整個表格的背景,然後設置一個堅實的背景和(請參閱this trick,這篇文章是關於實心邊框的,但我確信您可以使用棋盤格式的2x2 repeating bitmap)。

+0

我已經實現與按鈕形狀...,但我不能夠顯示在邊界表佈局 1)coupon_detail_table <形狀的xmlns : android =「#2D3C2D」android:「dashWidth =」10dip「android:dashGap =」android3Dip2「android: 「6DIP」 /> 我不知道爲什麼它不工作 – user680530 2011-03-30 12:13:38

+0

你不能只是卡在佈局文件中的形狀繪製 - 你需要在它自己的XML文件中定義它他繪製文件夾,然後將該drawable設置爲所需佈局中View的'android:background'。請參閱ApiDemos應用程序中的Graphics/Drawables演示和相關XML文件,以瞭解它的工作原理(http://developer.android.com/resources/samples/ApiDemos/index.html) – 2011-03-30 14:49:23