Ash
Ash

Reputation: 1241

Android TextView top and bottom line/border with a different colour

Is it possible to have the top and bottom line/border of a TextView a different colour, and the left and right line/border a different colour in XML? I have tried a few examples from here (stackoverflow) but they don't seem to work.

Thanks.

Upvotes: 0

Views: 7587

Answers (1)

Dory Zidon
Dory Zidon

Reputation: 10719

The best way to do this is to use a 9patch for background - http://developer.android.com/tools/help/draw9patch.html

But if you insist on doing it in the xml I would suggest you setup a shape and use it as background:

This will draw a line at the top which should create a line like background.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape android:shape="line">
        <stroke android:width="5dp" android:color="#FFFF00" />
        <solid android:color="#00000000" />

        <padding android:top="25dp" />

    </shape>
</item>
</layer-list>

Upvotes: 1

Related Questions