How to put a border around an Android TextView

0 votes
Is it possible to draw a border around an Android TextView?
Nov 23, 2022 in Android by Ashwini
• 5,430 points
900 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

The simple way is to add a view for your TextView. Example for the bottom border line:

<LinearLayout android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent">
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="10dp"
        android:text="@string/title"
        android:id="@+id/title_label"
        android:gravity="center_vertical"/>
    <View
        android:layout_width="fill_parent"
        android:layout_height="0.2dp"
        android:id="@+id/separator"
        android:visibility="visible"
        android:background="@android:color/darker_gray"/>

</LinearLayout>

For the other direction borders, please adjust the location of the separator view.

answered Nov 28, 2022 by sarit
• 1,830 points

edited 5 days ago

Related Questions In Android

0 votes
0 answers

How to define a circle shape in an Android XML drawable file?

I'm having some trouble locating the Android ...READ MORE

Nov 22, 2022 in Android by Edureka
• 12,690 points
2,470 views
0 votes
0 answers

How to put a <vector> in a <shape> in Android?

I'm trying to make customizable icons in ...READ MORE

Dec 8, 2022 in Android by Edureka
• 12,690 points
1,057 views
0 votes
0 answers

Android - How to download a file from a webserver

I'm getting a kml file from a ...READ MORE

Nov 22, 2022 in Android by Edureka
• 12,690 points
751 views
0 votes
0 answers

How to open WhatsApp using an Intent in your Android App?

I want an Intent to take control ...READ MORE

Nov 23, 2022 in Android by Ashwini
• 5,430 points
3,192 views
0 votes
1 answer

How can I add a border to a widget in Flutter?

To add a border to a widget ...READ MORE

answered Mar 1, 2023 in Android by vishalini
12,773 views
0 votes
0 answers

How to make grid view scroll horizontally not vertically in android?

I use a flexible Grid View. means ...READ MORE

Sep 21, 2022 in Android by Edureka
• 13,620 points
684 views
0 votes
1 answer
0 votes
1 answer

Kotlin Convert Bitcoin value into Satoshi Value

java.lang.NumberFormatException: For input string: "45,586" This means ...READ MORE

answered Apr 12, 2022 in Blockchain by Soham
• 9,710 points
988 views
0 votes
1 answer

How to write the Bitcoin logo as text?

Create a string in strings.xml like the ...READ MORE

answered Apr 12, 2022 in Blockchain by Aditya
• 7,680 points
1,147 views
0 votes
1 answer

Android backgroud image slow the app

You should have diferentiate sizes for deferent ...READ MORE

answered Jun 16, 2022 in Others by polo
• 1,480 points
657 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP