I use nested fragments, moving from one to another using code
ImageView search = (ImageView) root.findViewById(R.id.search);
search.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
transaction.addToBackStack(null);
transaction.replace(R.id.parent, ChildFragment.newInstance());
transaction.commit();
}
});
However, sometimes it happens that from a child fragment I can still click on the elements of the parent fragment, even if they are invisible (covered by the child fragment). In particular, this happens when a child has a simple layout like
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFF0D1"
android:id="@+id/child">
...some stuff...
</RelativeLayout>
but this will NOT happen when I use a nested layout
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFF0D1"
android:id="@+id/child">
<ScrollView
android:id="@+id/scr"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:padding="10dp">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
...same stuff...
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Does anyone know why this is happening?
source
share