2013-01-13 26 views
5

Tôi có nhiều hơn một elemen trong một xml .. listview, slipdrawer, edittext và nút ... tôi muốn trượt đơn đặt hàng ngăn kéo luôn ở phía trước của các yếu tố khác ... nhưng tôi không thể ..Z-index trong android?

đây xml tôi

<com.ltvie.chat.MultiDirectionSlidingDrawer 
    xmlns:my="http://schemas.android.com/apk/res/com.ltvie.chat" 
    android:id="@+id/drawer" 
    my:direction="topToBottom" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    my:handle="@+id/handle" 
    my:content="@+id/content" 
    > 
    <include 
     android:id="@id/content" 
     layout="@layout/pen_content" 
     android:gravity="top"   
     /> 
    <ImageView 
     android:id="@id/handle" 
     android:layout_width="wrap_content" 
     android:layout_height="5dp" 
     android:src="@drawable/sliding_drawer_handle_bottom" />   
</com.ltvie.chat.MultiDirectionSlidingDrawer> 

<ListView android:id="@+id/listView1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:stackFromBottom="true" 
    android:transcriptMode="alwaysScroll" 
    android:layout_above="@+id/InnerRelativeLayout" 
    android:layout_alignParentTop="true" 
/> 
<RelativeLayout 
    android:id="@+id/InnerRelativeLayout" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" > 
    <Button 
     android:text="kirim" 
     android:id="@+id/button_send" 
     android:layout_alignParentRight="true" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:onClick="tambahItems"   
     > 

    </Button>   
</RelativeLayout> 

kết quả của MyCode trong pict của tôi dưới đây: D

enter image description here

tôi muốn biết cách sửa nó?

liên quan,

Trả lời

18

Xml của bạn không chứa bố cục ngoài, nhưng tôi cho rằng bố cục tương đối. Trong một số RelativeLayout, các cấp z của các phần tử được xác định theo thứ tự chúng được thêm vào vùng chứa. Chế độ xem được thêm sau sẽ nằm ở trên cùng. Hãy thử di chuyển ngăn kéo trượt của bạn xuống đáy thùng chứa bên ngoài của bạn. Như thế này -

<ListView android:id="@+id/listView1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:stackFromBottom="true" 
    android:transcriptMode="alwaysScroll" 
    android:layout_above="@+id/InnerRelativeLayout" 
    android:layout_alignParentTop="true" 
/> 
<RelativeLayout 
    android:id="@+id/InnerRelativeLayout" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" > 
    <Button 
     android:text="kirim" 
     android:id="@+id/button_send" 
     android:layout_alignParentRight="true" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:onClick="tambahItems"   
     > 

    </Button>   
</RelativeLayout> 

<com.ltvie.chat.MultiDirectionSlidingDrawer 
    xmlns:my="http://schemas.android.com/apk/res/com.ltvie.chat" 
    android:id="@+id/drawer" 
    my:direction="topToBottom" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    my:handle="@+id/handle" 
    my:content="@+id/content" 
    > 
    <include 
     android:id="@id/content" 
     layout="@layout/pen_content" 
     android:gravity="top"   
     /> 
    <ImageView 
     android:id="@id/handle" 
     android:layout_width="wrap_content" 
     android:layout_height="5dp" 
     android:src="@drawable/sliding_drawer_handle_bottom" />   
</com.ltvie.chat.MultiDirectionSlidingDrawer> 
+0

có chứa bố cục bên ngoài, nhưng tôi chỉ hiển thị mã sự cố ... – ltvie

+0

đúng và bố cục bên ngoài bạn đã hiển thị là bố cục tương đối. Di chuyển toàn bộ khối ngăn trượt sang dưới cùng của mã xml bạn đã hiển thị. (xem chỉnh sửa). – iagreen

+0

slidingdrawer succes ở phía trước..nhưng tôi gặp vấn đề mới ... listview không hiển thị ,,, tôi gặp lỗi java.lang.ClassCastException: android.widget.listview – ltvie

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