1

how to put text in border

How can i add text over the border in android

Some think like this Text in Border CSS HTML

Community
  • 1
  • 1

2 Answers2

0

use this layout inside the layout copied from HERE

 <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:background="@android:color/white">

        <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:background="@android:color/white" android:padding="5dp"
            android:text="Testing"
            android:layout_marginLeft="30dp" android:textColor="@android:color/black" />

        <RelativeLayout
            android:layout_width="fill_parent" android:layout_height="fill_parent"
            android:background="@drawable/frame"
            android:orientation="vertical" android:padding="20dp"
            android:layout_centerVertical="true"
            android:layout_centerHorizontal="true">

            <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
                android:text="Main Content" android:layout_centerInParent="true" />
        </RelativeLayout>
    </RelativeLayout>

create a frame.xml inside drawable

<shape xmlns:android="schemas.android.com/apk/res/android">
<stroke android:width="1px" android:color="@color/black" /><padding android:left="1dp" 
android:top="1dp" 
android:right="1dp" 
android:bottom="1dp" />
</shape>
Community
  • 1
  • 1
Nouman Shah
  • 534
  • 1
  • 9
  • 22
0

You can also achieve this in non ethical way..its quite a shortcut way to implement this....Try this...

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff" >

    <EditText
        android:id="@+id/edittext"
        android:layout_width="fill_parent"
        android:layout_height="90dp"
        android:layout_alignLeft="@+id/button"
        android:layout_below="@+id/textView1"
        android:layout_marginTop="61dp"
        android:background="@drawable/border"
        android:ems="10"
        android:inputType="text"
        android:text="hia" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="46dp"
        android:background="#ffffff"
        android:clickable="false"
        android:text="vvvv"
        android:textSize="24dp" />

</RelativeLayout>
Rajakumar
  • 907
  • 1
  • 7
  • 17