2013-01-31 50 views

Trả lời

4

Nhanh chóng và bẩn:

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

@drawable/rectangle là trong một file drawable rectangle.xml như thế này:

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

tôi thấy cách này là nhanh chóng, nhưng làm thế nào là nó bẩn? Đây có phải là những gì mà thẻ dành cho không? Tôi cho rằng bạn cũng có thể xác định bố cục tiêu đề riêng và đưa nó vào đầu bằng cách sử dụng

+0

Điều này chắc chắn có thể là bố cục riêng biệt. – anthropomo

Các vấn đề liên quan