danmacleod
Newbie
I'm having an issue with Fragments and my Appbar. I have an Activity that uses fragments. When the Activity is first loaded, I use the FragmentManager to load the initial Fragment. When the user selects an option, I use the FragmentManager to 'replace' the current fragment with the new Fragment. When the new Fragment's UI is displayed, the toolbar title is not shown correctly. If I give focus to the EditText field the soft keyboard is opened and the title will re-display correctly. The best I can tell is when I give focus to the EditText field it forces the toolbar to re-paint. I've tried to 'invalidate' the toolbar but that didn't work. Any idea's?
LOADING THE FRAGMENTS:
FRAGMENT LAYOUT SNIPPET

LOADING THE FRAGMENTS:
Code:
private void loadFragment( Fragment fragment, String tag ) {
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace( R.id.content_frame, fragment, tag ).addToBackStack( tag ).commit();
}
FRAGMENT LAYOUT SNIPPET
Code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".activities.NitroxActivity">
<!-- include the Toolbar -->
<include layout="@layout/appbar_content" />
<!-- scrolling page content -->
<android.support.v4.widget.NestedScrollView
android:id="@+id/main_nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:fillViewport="true"
app:layout_behavior="[USER=696546]@String[/USER]/appbar_scrolling_view_behavior">
<android.support.constraint.ConstraintLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/constraint_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="[USER=696546]@String[/USER]/appbar_scrolling_view_behavior">
<!-- screen title -->
<TextView
android:id="@+id/title_txt"
style="[USER=19691]@Style[/USER]/Headers"
android:layout_width="314dp"
android:layout_height="32dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="[USER=696546]@String[/USER]/partial_pressure_of_oxygen"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.492"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
AppBar
<android.support.design.widget.AppBarLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/appbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="[USER=19691]@Style[/USER]/AppTheme.AppBarOverlay"
app:expanded="false"
android:fitsSystemWindows="true">
<!-- android:layout_height="?attr/actionBarSize" -->
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="@color/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/expanded_image"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:src="@drawable/toolbar_image"
android:contentDescription="[USER=696546]@String[/USER]/dive_flag"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimaryDark"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="[USER=19691]@Style[/USER]/AppTheme.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
