2012-11-20 3 views
4

Je veux faire une bordure avec un titre autour d'un LinearLayout comme sur cette image.Border avec le titre autour d'un LinearLayout

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

J'ai déjà la frontière.
Comment puis-je ajouter le titre?

J'ai créé la bordure en créant un fichier .xml dans le dossier drawable. Là j'ai fait une forme et ensuite j'ai mis le fond de la disposition linéaire comme cette forme.

J'utilise Niveau API 8.

+0

Bienvenue sur StackOverflow. J'ai modifié votre question pour corriger quelques erreurs grammaticales afin d'améliorer la lisibilité. J'ai également fait ressortir davantage votre question afin que votre problème soit immédiatement évident. – phant0m

Répondre

1

Vous pouvez jeter un oeil à la mise en page Frame Android. Un bon tutoriel peut être trouvé here ou vous pouvez lire le dev guides.

1

Selon @ la réponse de Radu, vous pouvez voir un exemple:

<?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> 

Et @ drawable/rectangle est dans un fichier rectangle.xml drawable comme ceci:

<?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>