Java_Android
Java_Android

Reputation: 745

Android - LinearLayout Border

I am trying to make a border to my page, but i failed to do that.. my code is

@drawable/custom_border

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="0dp"/> 
<padding android:left="2dp" android:right="2dp" android:top="2dp" android:bottom="2dp"/>
<solid android:color="@color/Black"/>
</shape>

My problem is the that, the Black color is setting to whole view(as a background), i want a border of black color not a background of black color. What I am failing to do?? Please Help.

Upvotes: 1

Views: 5278

Answers (2)

jbihan
jbihan

Reputation: 3099

The solid attribute is the background color. You should try to set it to

<solid android:color="@android:color/transparent" />

To set the color of the border :

<stroke
    android:width="1dp"
    android:color="@color/Black" />

Upvotes: 2

codeMagic
codeMagic

Reputation: 44571

I think what you need to do is change <solid> to <stroke>. So try changing

<solid android:color="@color/Black"/>

to

<stroke android:color="@color/Black"/>

<solid> is a fill where` will be used as your border.

Upvotes: 1

Related Questions