4

I have an issue with soft keyboard on my project. I already have set my Manifest file with

android:windowSoftInputMode="adjustPan"

With that my keyboard and EditText are visible. But just like the question linked below, the buttons on the bottom of the screen are pushing up along with keyboard.

https://stackoverflow.com/questions/5516216/how-to-avoid-soft-keyboard-pushing-up-my-layout#=

My layout consistis of a RelativeLayout base with 2 LinearLayout (One Top, One bottom with buttons) and a ScrollView on middle getting the rest of content. When I try to set the option

android:isScrollContainer="false" 

on my ScrollView this time my Action bar pushes up and be hidden from layout.

I want a way to keyboard get over the bottom linear layout scroll the content of scrollview and do not pushes up action bar.

Any suggestions?

Thank you!

By the way, my scroll view has a lot of spinners, EditTexts and an AutoSuggest

Working "Solution" --> To help to find the answer

If I change RelativeLayout to LinearLayout with vertical orientation and remove from manifest this property android:windowSoftInputMode="adjustPan" I have the effect I want, action bar don't disappears and bottom buttons don't pushes up. The problem is, I lost by bottom buttons to be stacked at bottom. Sometimes the ScrollView is smaller than the device window, so this solution just helped me, but now solve my real problem.

Informations:

<activity
   android:name=".app.HomeActivity"
   android:label="@string/title_activity_home"
   android:launchMode="singleTop"
   android:screenOrientation="portrait"
   android:windowSoftInputMode="adjustPan"/>

Theme of application:

<style name="CustomActionBarTheme" parent="@style/AppTheme">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
</style>

<!-- ActionBar styles -->
<style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar">
    <item name="android:background">@drawable/shape_bar</item>
    <item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
</style>

XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:id="@+id/fragment_detalhes_pedido2_linear_top"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="@dimen/activity_vertical_margin"
            android:paddingBottom="@dimen/activity_vertical_margin"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:background="@color/font_white_color"
            android:orientation="horizontal"
            android:gravity="center_vertical">

            <ImageView
                android:layout_width="@dimen/icon_size_default"
                android:layout_height="@dimen/icon_size_default"
                android:layout_gravity="center_vertical"
                android:contentDescription="@string/app_name"
                android:src="@drawable/icon_lista_clientes" />

            <br.newm.afvcore.layout.NewmTextView
                android:id="@+id/fragment_detalhes_pedido2_txt_cliente"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/activity_horizontal_margin"
                android:text="Cliente Selecionado"
                android:textColor="@color/font_default_color"
                android:textSize="@dimen/font_size_default"
                android:textStyle="bold|italic" />
        </LinearLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#696969" />

    </LinearLayout>

    <ScrollView
        android:id="@+id/fragment_scroll_datalhes2_miolo"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/fragment_detalhes_pedido2_linear_bottom"
        android:layout_below="@+id/fragment_detalhes_pedido2_linear_top"></ScrollView>

    <LinearLayout
        android:id="@+id/fragment_detalhes_pedido2_linear_bottom"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="@dimen/activity_vertical_margin"
        android:orientation="vertical">

        <View
            android:layout_width="match_parent"
            android:layout_height="0.1dp"
            android:background="@color/cinza_linha" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/activity_vertical_margin"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:orientation="horizontal"
            android:weightSum="1">

            <LinearLayout
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="0.35">

                <br.newm.afvcore.layout.NewmTextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textColor="@color/azul_letras"
                    android:textSize="@dimen/font_size_default"
                    android:text="Qtd:"
                    android:textStyle="bold" />

                <br.newm.afvcore.layout.NewmTextView
                    android:id="@+id/fragment_detalhes_pedido2_txt_qtd"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textColor="@color/font_default_color"
                    android:textSize="@dimen/font_size_default"
                    android:text="999999999"
                    android:layout_marginLeft="5dp"
                    android:textStyle="bold" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="0.65"
                android:layout_marginLeft="5dp"
                android:gravity="right">

                <br.newm.afvcore.layout.NewmTextView
                    android:id="@+id/fragment_detalhes_pedido2_lbl_valor_total"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textColor="@color/azul_letras"
                    android:textSize="@dimen/font_size_default"
                    android:text="Total:"
                    android:textStyle="bold" />

                <br.newm.afvcore.layout.NewmTextView
                    android:id="@+id/fragment_detalhes_pedido2_txt_valor_total"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textColor="@color/font_default_color"
                    android:textSize="@dimen/font_size_default"
                    android:text="R$ 9.999.999,00"
                    android:layout_marginLeft="5dp"
                    android:textStyle="bold" />

            </LinearLayout>
        </LinearLayout>

        <LinearLayout
            android:id="@+id/fragment_detalhes_pedido2_linear_btn"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/activity_vertical_margin"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:gravity="center_vertical">

            <Button
                android:id="@+id/fragment_detalhes_pedido2_btn_salvar"
                android:layout_width="0dip"
                android:layout_height="@dimen/btn_size_default"
                android:layout_weight="1"
                android:text="Salvar"
                android:background="@drawable/shape_btn_azul"
                android:textColor="@color/font_white_color"
                android:textSize="@dimen/font_size_default"
                android:textStyle="bold|italic" />

            <Button
                android:id="@+id/fragment_detalhes_pedido2_btn_reenviar_copia"
                android:layout_width="0dip"
                android:layout_height="@dimen/btn_size_default"
                android:layout_weight="1"
                android:text="Reenviar cópia do pedido"
                android:background="@drawable/shape_btn_azul"
                android:textColor="@color/font_white_color"
                android:textSize="@dimen/font_size_default"
                android:textStyle="bold|italic"
                android:visibility="gone" />

            <Button
                android:id="@+id/fragment_detalhes_pedido2_btn_finalizar"
                android:layout_width="0dip"
                android:layout_height="@dimen/btn_size_default"
                android:layout_marginLeft="@dimen/activity_horizontal_margin"
                android:layout_weight="1"
                android:text="Finalizar"
                android:background="@drawable/shape_btn_azul"
                android:textColor="@color/font_white_color"
                android:textSize="@dimen/font_size_default"
                android:textStyle="bold|italic" />

        </LinearLayout>

    </LinearLayout>

</RelativeLayout>
Community
  • 1
  • 1
Heitor
  • 83
  • 1
  • 7

3 Answers3

6

It might be late to be answering this question but I faced it and found a solution so thought of sharing it.

give the property

android:isScrollContainer="false" to your parent in Layout

and

android:windowSoftInputMode="adjustResize" for Activity in AndroidManifest.xml

Logic
  • 2,230
  • 2
  • 24
  • 41
  • i have a fairly complicated layout with a constraint layout with items constraint to its bottom inside a nested scroll view which would push the toolbar up unless i added a stupid amount of margin bottom but just adding android:isScrollContainer="true" fixed it many thanks – martinseal1987 Apr 26 '20 at 07:28
-1

try this in your manifest: android:windowSoftInputMode="adjustResize|stateHidden"

Amit Joki
  • 58,320
  • 7
  • 77
  • 95
Ebin James
  • 162
  • 7
  • try this android:windowSoftInputMode="stateHidden|stateUnchanged|adjustPan". and let me know – Ebin James Dec 02 '14 at 12:11
  • this time, actionbar get hidden but didnt pushed buttons up. Same effect as just setting android:windowSoftInputMode="adjustPan" – Heitor Dec 02 '14 at 12:15
  • Sure on problem description, by the way im using fragments too. (Don't know if it matters) – Heitor Dec 02 '14 at 12:22
  • change android:windowSoftInputMode="adjustPan" to android:windowSoftInputMode="stateHidden|stateUnchanged|adjustPan". did you write any code to remove action bar – Ebin James Dec 02 '14 at 12:29
  • already tried that =/ the action bar hiddes from layout, but the keyboard get over the bottom buttons. And I didn write code to remove the action bar – Heitor Dec 02 '14 at 12:36
  • Hey, if you can see my "working solution" on problem description, perhaps can help find something =/ – Heitor Dec 02 '14 at 12:46
-1

android:windowSoftInputMode="adjustNothing" try this

Amit Joki
  • 58,320
  • 7
  • 77
  • 95
Ganesh Kanna
  • 2,269
  • 1
  • 19
  • 29