jiduvah
jiduvah

Reputation: 5168

Wrap a layout in a border

I am trying to create a border that will go around a number of text boxes. I have been able to do this by defining a shape in XML and then using that shape as my background. Here is the defined shape.

<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>

and here is how I used it. Just on a textview at the moment.

<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"/>

This actually draws the border as expected but the color within the board i.e. the background of the textview is black. I can't work out why this is. Any help of guesses to push me in the right direction are appreciated.

Thanks

Upvotes: 1

Views: 573

Answers (1)

Michael
Michael

Reputation: 54725

Try adding <solid android:color="#ffffff" /> to your shape definition.

Upvotes: 2

Related Questions