This is my first question here, after 2 hours of searching a similar case I couldn't find one therefor this post.
The problem is that I have an activity with a toolbar (v7 support toolbar) and a navigation drawer. This all works perfectly. The main activity has a fragment container, where I put different fragments (via the navigation drawer). Everything worked perfectly until I added a EditText to a fragment. When I select the EditText to input some text the softkeyboard is shown and the toolbar resizes untill the bottom is aligned with the softkeyboard (The actual height increases), I can not yet post images so I hope this is detailed enough. The fragment without input selected is displayed normally. The EditText is actually underneath the softKeyboard (at least the selection indicator can be seen there).
this is the layout file from the mainactivity:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/main_color_500">
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_height="match_parent"
android:layout_width="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:paddingBottom="0dp"
android:orientation="vertical"
tools:context="com.joost.smartplanner.MainFragmentActivity">
<android.support.v7.widget.Toolbar 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="wrap_content"
android:background="@color/main_color_500"
android:fitsSystemWindows="true"
android:elevation="4dp"
android:id="@id/app_bar"
app:theme="@style/CustomToolbarStyle">
</android.support.v7.widget.Toolbar>
<FrameLayout
android:id="@+id/mainFragmentContainer"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/grey_100"
android:padding="@dimen/zero_padding"
android:gravity="top"
android:orientation="horizontal"
android:focusable="true">
</FrameLayout>
</LinearLayout>
<fragment
android:id="@+id/fragment_navigation_drawer"
android:layout_width="@dimen/nav_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
app:layout="@layout/fragment_navigation_drawer"
android:name="com.joost.smartplanner.NavigationDrawerFragment" />
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
The fragment containing the editText:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/fragment_bg_white"
android:focusable="true"
tools:context="com.joost.smartplanner.CreateEventFragment">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/create_event_scrollview">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/divider"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"/>
<!-- Event name part -->
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:imeOptions="flagNoExtractUi"
android:hint="Event name"
android:padding="8dp"
android:ems="8"
android:focusable="true"
android:clickable="true"
android:id="@+id/editText" />
</LinearLayout>
</ScrollView>
</LinearLayout>
And at last the toolbar initiation code in the MainActivity onCreate:
//Toolbar initiation
toolbar = (Toolbar) findViewById(R.id.app_bar);
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
getSupportActionBar().setTitle("");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
toolbar.setNavigationOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
}
});
toolbar.inflateMenu(R.menu.menu_main);
One thing that I tried to remove this problem is to set a fixed height for the toolbar, instead of the wrap_content value. This partially fixes the problem that the toolbar stays the same height but the icons inside the toolbar disappear, and in my opinion hard-coding a height that normally works fine is not the right solution.