2011-12-29 35 views
4

爲什麼android:clipChildren =「false」不起作用?我想實現與CSS overflow相同的效果:可見,以便即使位於其父級佈局之外的子視圖也可見。我嘗試過這樣的事情,雖然Eclipse中的圖形佈局顯示正確的行爲,但在手機上它不起作用。Android ViewGroup剪輯不起作用

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="#0000FF" 
android:clipChildren="false" 
android:clipToPadding="false" > 

<RelativeLayout 
    android:layout_width="100dp" 
    android:layout_height="100dp" 
    android:layout_alignParentLeft="true" 
    android:background="#FF0000" 
    android:clipChildren="false" 
    android:clipToPadding="false" > 

    <RelativeLayout 
     android:layout_width="50dp" 
     android:layout_height="50dp" 
     android:layout_marginLeft="120dp" 
     android:background="#00FF00" /> 
</RelativeLayout> 

</RelativeLayout> 
+0

這很有趣,但我不能相反讓父母把他們的孩子剪短。但我有LinearLayout。也許這是原因? – Gangnus 2012-01-18 16:14:17

回答

1

我,想類似的東西,現在,當我對所有的父母使用展位android:clipChildren="false"下一個問題是,如果在重疊的孩子是重新繪製自己喜歡的ListView東西它僅適用,Android的話都忘重繪我們的孩子並且它消失了:-(

唯一的辦法是在重建的孩子每次重新繪製視圖之後手動調用.invalidate():-( 我還發現重疊子的至少小和平必須在其父項。

另一個問題是在接收觸摸/點擊事件中爭奪w在父母之外。我沒有找到任何解決方案。