I have an activity.xml
.
As you can see, it's a relative layout. I am hoping that the Frame layout which will contain the fragment, will be below the toolbar.
The fragment is added, for sure. But it's added at the top, covering the toolbar. Just wondering what I am doing wrong.
The website wouldn't let me add code for some reason. It was telling me it's not properly formatted. here is the activity.xml layout.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" android:fitsSystemWindows="true"
>
<!--scroll|snap-->
<android.support.v7.widget.Toolbar
android:id="@+id/appToolBar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolBarHeight"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<FrameLayout
android:id="@android:id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/appToolBar"/>
</RelativeLayout>
And this is simply what I am doing in the Activity.java file.
getFragmentManager().beginTransaction().add(android.R.id.content, SetupFrag.createInstance(false), SETUP_FRAGMENT).commit();
You're using an existing id, @android:id/content
You should use +
to add your own ID, @+id/content
, otherwise the fragment is being added to the content view (the level above your activity layout).