How to add an edge to a Textview per code?

Asked

Viewed 3,167 times

2

I am making a dynamic form and would like to add an embroidery around a set with a Textview and an Edittext as in the code below:

TextView tv = new TextView(this);
        tv.setText(vet[0]);

        EditText et = new EditText(this);
        et.setSingleLine();
        et.setText("");

I would like to put this content on a very simple edge, as it is possible in a very simple way

  • If the answer was helpful and solved the problem check as correct @daniel12345smith, so others can benefit.

1 answer

3

VIA . XML

I created an . xml file

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

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

    <stroke
        android:width="2dp"
        android:color="sua cor" />

</shape>

With this you can apply within your Textview a "background" that actually is an edge.

<TextView
      android:background="@drawable/text_view_border" />

Via code :

et.setBackgroundDrawable(new Border("cor","espessura));

Browser other questions tagged

You are not signed in. Login or sign up in order to post.