3

I have a simple layout with:

  • top bar (like action bar) with save and back button
  • and below a scroll view with some EditText inside... (check the image below),

enter image description here

When I call keyboard, my view is push above... I would like my Top Bar to stay always visible and fixed on the top... (check below the image of what is happening and what I would like to happen)

enter image description here

I tried several solutions with android:windowSoftInputMode, putting the top bar as relative layout and set isScrollContainer in scrollview but none have 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 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 find out, that when you put the activity as Full Screen:

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

, the windows starts to act different from usual: 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 in here, this is how it's working, and it seems that there is no interest in changing it.

So, I tried the Joseph Johnson's AndroidBug5497Workaround, but I always end up with a "extra" blank bar above my keyboard, and the View steel doesn't show as I want it to...

Does anyone have a nice/simple solution to this problem?

Community
  • 1
  • 1
slyzer
  • 215
  • 1
  • 19

2 Answers2

0

android:windowSoftInputMode="adjustResize" in the manifest for your activity will keep the top bar in view and resize the scrollview to use what room is left.

The only issue I can see with this would be lining up the edit text with the viewable area after it has been resized (if this is needed)

Chris Handy
  • 366
  • 1
  • 5
  • For you first suggestion, it doesn't work for me. For the second one, that could be a nice idea... I could set `android:windowSoftInputMode="adjustNothing"`, and then set `ScrollView` for the position I want... Is easy to change the position of the `ScrollView` for a specific position in the view? – slyzer Jan 13 '15 at 12:36
  • It is worth a try, for the scrollview change the height to `wrap_content` as it should not be the same size as the parent. – Chris Handy Jan 13 '15 at 12:42
0

Add this to the activity tag in the manifest:

android:windowSoftInputMode="adjustPan"

Or programmatically:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
Pygmalion
  • 561
  • 5
  • 16
  • Thanks for the comment... I believe that I had tried that... but just to be sure, I made the changes, and still doesn't work... any other idea? – slyzer Jan 13 '15 at 15:21