mercredi 20 mai 2015

android : apply clipChildren only for one child

<RelativeLayout
                android:id="@+id/RelativeLayout_grand_parent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" >
                <ListView
                    android:id="@+id/ListView_grand_parent"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent" />
            </RelativeLayout>
////////////////////////////

ListView holds the below row layout. 

/////// row_layout.xml ///////
<RelativeLayout
                android:id="@+id/RelativeLayout_parent"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" >
                <ImageView
                    android:id="@+id/ImageView_child"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/heart_icon" />
            </RelativeLayout>
////////////////////////////

Suppose there is RelativeLayout_grand_parent parent of ListView_grand_parent. ListView_grand_parent holds the row_layout.xml as it's row layout. So, now ListView_grand_parent is parent of RelativeLayout_parent. RelativeLayout_parent is parent of ImageView_child.

I need to animate the child "ImageView_child" and move it outside the parent,
than I used below method : 
public void disableClipOnParents(View v) {
    if (v.getParent() == null) {
        return;
    }

    if (v instanceof ViewGroup) {
        ((ViewGroup) v).setClipChildren(false);
    }

    if (v.getParent() instanceof View) {
        disableClipOnParents((View) v.getParent());
    }
}

It worked fine, while animating ImageView_child it is no more clipped by it's parent. But while scrolling the list, ListView_grand_parent also comes over the RelativeLayout_grand_parent and action bar.

My requirment is :

  • ImageView_child should not be clipped by ListView_grand_parent and RelativeLayout_grand_parent.
  • ListView_grand_parent should be clipped by RelativeLayout_grand_parent.

Is it possible to disable the clipping only for one child ?

Aucun commentaire:

Enregistrer un commentaire