Android - top layout bar is displayed when keyboard is displayed
I have a simple layout with:
- top bar (like action bar) with save and return button
- and below scroll with some
EditText
inside ... (check image below),
When I call the keyboard, my view clicks above ... I would like my Top Bar to remain always visible and fixed at the top ... (check below image of what is happening and what I would like to happen)
I tried several solutions with android:windowSoftInputMode
, putting the top bar as relative layout and setting isScrollContainer
to scrollview
, but none worked for me ...
Code below:
<RelativeLayout
android:id="@+id/llWriteCommentWall"
style="@style/TextSubSeparator"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
style="@style/TextSubSeparator"
android:layout_marginBottom="@dimen/margin_separator_bottom"
android:layout_alignParentTop="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="left|center_horizontal|center_vertical"
android:orientation="horizontal"
android:layout_marginTop="@dimen/margin_title_top"
android:layout_marginBottom="@dimen/margin_title_bottom"
android:layout_marginLeft="@dimen/margin_title_left"
android:layout_marginRight="@dimen/margin_title_right"
>
<ImageView
android:id="@+id/ivMainMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="@drawable/tk_btn_home"
android:onClick="clickHome"/>
</LinearLayout>
<TextView
android:id="@+id/tvSeconHeader"
android:text="@string/title"
android:layout_width="match_parent"
android:layout_weight="2.5"
android:layout_height="match_parent"
android:gravity="center"
style="@style/TextTileHealth"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="right|center_horizontal"
android:orientation="horizontal"
android:layout_marginTop="@dimen/margin_title_top"
android:layout_marginBottom="@dimen/margin_title_bottom"
android:layout_marginLeft="@dimen/margin_title_left"
android:layout_marginRight="@dimen/margin_title_right">
<ImageView
android:id="@+id/ivSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="@drawable/tk_btn_tab_save"
android:onClick="clickSave"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:isScrollContainer="false">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_separator_bottom"
android:gravity="center">
<!-- EditBoxes -->
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:id="@+id/et1"
style="@style/TextEditBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:digits="0123456789."
android:inputType="numberDecimal"
android:maxLength="3"
android:layout_weight="0.33"
android:gravity="center"
android:ems="3"
android:layout_marginBottom="10dp"/>
<EditText
android:id="@+id/et2"
style="@style/TextEditBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:digits="0123456789."
android:inputType="numberDecimal"
android:maxLength="3"
android:layout_weight="0.33"
android:gravity="center"
android:ems="3"
android:layout_marginBottom="10dp"/>
<EditText
android:id="@+id/et3"
style="@style/TextEditBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:digits="0123456789."
android:inputType="numberDecimal"
android:maxLength="3"
android:layout_weight="0.33"
android:gravity="center"
android:ems="3"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
And the manifest:
<activity
android:name="com.example.slyzer.gui.new.NewValue"
android:label="@string/app_name"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait">
</activity>
EDIT:
I recently found out that when you put the activity in fullscreen mode:
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
windows start to act differently: https://code.google.com/p/android/issues/detail?id=5497&q=fullscreen&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars
and as described by Dianne Hackborn here , this is how it works and there seems to be no interest in changing it.
So I tried Joseph Johnson's AndroidBug5497Workaround , but I always end up with an "extra" blank panel above my keyboard, and the "View" steel doesn't show how I want it ...
Does anyone have a good / simple solution to this problem?
source to share