2011-04-28 52 views
1

我正在嘗試創建一個將圍繞多個文本框的邊框。我已經能夠通過在XML中定義形狀並將該形狀用作背景來實現這一點。這是定義的形狀。將佈局包裝在邊框中

<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <stroke android:width="1dp" android:color="#787878" /> 
    <padding android:left="7dp" android:top="7dp" 
      android:right="7dp" android:bottom="7dp" /> 
    <corners android:radius="4dp" /> 
</shape> 

以下是我如何使用它。目前只是一個textview。

<TextView 
    android:background="@drawable/my_border" 
    android:id="@+id/item_text" 
    android:layout_margin="5dip" 
    android:layout_height="wrap_content" 
    android:textSize="16sp" 
    android:layout_centerHorizontal="true" 
    android:text="@string/item_text" 
    android:textColor="#787878" 
    android:layout_width="wrap_content" 
    android:textStyle="bold"/> 

這實際上繪製預期的邊框,但董事會即TextView的背景中的顏色是黑色。我無法弄清楚爲什麼會這樣。任何幫助猜測推動我在正確的方向感謝。

感謝

回答

2

嘗試增加<solid android:color="#ffffff" />shape定義。

+0

非常感謝。 – jiduvah 2011-04-28 15:39:02