2012-11-20 152 views
4

我想在此圖片上圍繞LinearLayout標題製作邊框。帶有LinearLayout標題的邊框

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

我已經有邊界。
如何添加標題?

我通過在可繪製文件夾中製作.xml文件創建了邊框。在那裏我做了一個形狀,然後將線形佈局的背景設置爲這種形狀。

我正在使用API​​級別8.

+0

歡迎StackOverflow上。我編輯了您的問題,以修復一些語法錯誤以幫助提高可讀性。我也讓你的問題更加突出,所以很明顯你的問題是什麼。 – phant0m

回答

1

您可能需要查看Android Frame Layout。

可以找到一個很好的教程 here或者您可能想要閱讀dev guides

1

據@拉杜的答案,你可以看到一個例子:

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

而@繪製/矩形以可抽拉rectangle.xml文件是這樣的:

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