I have a situation where a Button belonging to an Activity is always on top (visible) even after I add a fragment to a fragment container but once I change the element type to TextView it stays behind the new fragment like it should.
The element as TextView - stays behind the newly added fragment
<TextView
android:layout_width="100dp"
android:layout_height="50dp"
android:id="@+id/openAdFilteringButton"
android:text="Filters"
android:onClick="openAdFiltering"
android:layout_marginBottom="80dp"
android:layout_gravity="center|bottom"/>
The element as Button - comes on top of the newly added fragment (stays visible)
<Button
android:layout_width="100dp"
android:layout_height="50dp"
android:id="@+id/openAdFilteringButton"
android:text="Filters"
android:onClick="openAdFiltering"
android:layout_marginBottom="80dp"
android:layout_gravity="center|bottom"/>
The element is a child of FrameLayout.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
Note that this FrameLayout is the fragment container meaning I am adding the fragment to this FrameLayout:
FragmentTransaction.add(R.id.fragment_container, adFilteringFragment, "AdFilteringFragment").addToBackStack("AreaInterFrag").commit();
What do I need tell the button so that he will act like TextView and stay behind the fragment. Where does this difference in behavior (Button vs TextView) come from? Thanks!