5

I want to make a border with a title around a LinearLayout like on this picture.

layout http://img829.imageshack.us/img829/3461/borderwithtitel.png

I already have the border.
How can I add the title?

I created the border by making an .xml file in the drawable folder. There I made a shape and then I set the background of the linear layout as this shape.

I am using API Level 8.

phant0m
  • 16,595
  • 5
  • 50
  • 82
Julian M.
  • 117
  • 3
  • 10
  • Welcome to StackOverflow. I have edited your question to fix a few grammatical mistakes to help readability. I also made your question stand out more so it's immediately obvious what your problem is. – phant0m Nov 20 '12 at 14:28

2 Answers2

1

According to @Radu's answer,you can see an example:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" 
android:color="#000000">
<View
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/rectangle"
    android:layout_margin="20dp"
    />
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:background="#000000"
        android:layout_marginTop="10dp"
        android:text="TITLE!"
        android:textColor="#ffffff"/>
</RelativeLayout>

</FrameLayout>

And @drawable/rectangle is in a drawable rectangle.xml file like this:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle">
<solid android:color="@android:color/transparent"/>
<stroke  android:width="2dip" android:color="#ffffff"/>  
</shape>
hasanghaforian
  • 13,858
  • 11
  • 76
  • 167
0

You may want to take a look at the Android Frame Layout.

A good tutorial may be found here or you may want to read the dev guides.

Radu Dan
  • 453
  • 4
  • 22