软键盘推上布局或隐藏操作栏

4
我是一名有用的助手,可以为您翻译文本。以下是需要翻译的内容:

我的项目中软键盘出现了问题。我已经在清单文件中进行了设置。

android:windowSoftInputMode="adjustPan"

现在我的键盘和EditText都可见了。但是就像下面链接的问题一样,屏幕底部的按钮也随着键盘一起往上推。

https://dev59.com/W2035IYBdhLWcg3wSN4G=

我的布局由一个RelativeLayout基础和两个LinearLayout(一个顶部,一个底部带有按钮),以及一个ScrollView在中间获取其余内容。当我尝试设置选项时。
android:isScrollContainer="false" 

这次在我的ScrollView上,我的Action bar被推上并从布局中隐藏了。
我想要一种方法,让键盘覆盖底部线性布局滚动ScrollView的内容,并且不推上操作栏。
有什么建议吗?
谢谢!
顺便说一下,我的ScrollView有很多旋转器、EditTexts和AutoSuggest。
“解决方案”-->帮助找到答案
如果我将RelativeLayout更改为具有垂直方向的LinearLayout,并从清单中删除此属性android:windowSoftInputMode="adjustPan",我就可以得到想要的效果,操作栏不会消失,底部按钮也不会被推上。问题是,我失去了底部按钮叠放在底部的效果。有时ScrollView比设备窗口小,所以这个解决方案只是帮了我一个忙,但没有解决我的真正问题。
信息:
<activity
   android:name=".app.HomeActivity"
   android:label="@string/title_activity_home"
   android:launchMode="singleTop"
   android:screenOrientation="portrait"
   android:windowSoftInputMode="adjustPan"/>

应用主题:
<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>

http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts - Krishnabhadra
你解决了吗? - CodeMonkey
3个回答

6

也许回答这个问题有点晚了,但我也遇到过同样的问题,并找到了解决方案,所以想分享一下。

Layout中给你的父容器添加属性android:isScrollContainer="false"

AndroidManifest.xml中给Activity添加属性android:windowSoftInputMode="adjustResize"


我有一个相当复杂的布局,其中包含一个约束布局和一些被约束到其底部的项目,放在一个嵌套的滚动视图中。如果我不添加大量的底部边距,滚动视图会将工具栏推上去,但只需添加android:isScrollContainer="true"即可解决问题。非常感谢! - martinseal1987

-1

在你的清单文件中尝试这个: android:windowSoftInputMode="adjustResize|stateHidden"


尝试使用android:windowSoftInputMode="stateHidden|stateUnchanged|adjustPan",然后告诉我。 - Ebin James
这次,ActionBar被隐藏了,但按钮没有被推上去。和设置android:windowSoftInputMode="adjustPan"的效果一样。 - Heitor
问题描述没问题,顺便说一下我也在使用片段(不知道是否有影响)。 - Heitor
将android:windowSoftInputMode="adjustPan"更改为android:windowSoftInputMode="stateHidden|stateUnchanged|adjustPan"。您是否编写了任何代码以删除操作栏? - Ebin James
已经尝试过了 =/ 操作栏从布局中隐藏,但键盘会覆盖底部按钮。我没有编写代码来移除操作栏。 - Heitor
嘿,如果你能在问题描述中看到我的“工作解决方案”,也许可以帮助找到一些东西 =/ - Heitor

-1

android:windowSoftInputMode="adjustNothing" 试试这个


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接