Android软键盘仅浮动特定布局 [英] Android Soft keyboard float only specific layout
问题描述
我有一个布局,下面的代码
I have a layout, code below
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!--some stuff here-->
<LinearLayout
android:id="@+id/layout1"
android:layout_alignParentBottom="true"
android:layout_above="@+id/layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5"
/>
<ImageButton
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleType="fitStart"
android:layout_marginLeft="5dp"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:src="@drawable/ic_menu_send"/>
</LinearLayout>
<LinearLayout
android:id="@+id/layout2"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!--some stuff here-->
</LinearLayout>
</RelativeLayout>
在上面的代码中,当显示键盘时,我希望layout2
停留在bottom
和layout1
至go up with keyboard
中.如果我添加android:windowSoftInputMode="adjustPan|adjustResize"
,则两个布局都停留在底部.请帮助
In the above code when keyboard is show i want layout2
to stay in the bottom
and layout1
to go up with keyboard
. if i add android:windowSoftInputMode="adjustPan|adjustResize"
both layout stay in bottom. please help
推荐答案
您可以说这不起作用
android:windowSoftInputMode="adjustPan|adjustResize"
只需对此进行更改
android:windowSoftInputMode="stateHidden"
还有以下布局中的一件事
and one more thing in your below layout
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!--some stuff here-->
<LinearLayout
android:id="@+id/layout1"
android:layout_alignParentBottom="true"
android:layout_above="@+id/layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5"
/>
<ImageButton
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleType="fitStart"
android:layout_marginLeft="5dp"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:src="@drawable/ic_menu_send"/>
</LinearLayout>
<LinearLayout
android:id="@+id/layout2"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/colorPrimary">
<!--some stuff here-->
</LinearLayout>
</RelativeLayout>
注意:
在将此属性android:layout_above="@+id/layout2"
应用于LinearLayout
的layout1
之后,请删除该属性android:layout_alignParentBottom="true"
,您不需要它.
Keep in Mind :
When you have applied this property android:layout_above="@+id/layout2"
to layout1
of your LinearLayout
then remove this property android:layout_alignParentBottom="true"
you don't require it.
所以现在看起来像这样
<LinearLayout
android:id="@+id/layout1"
android:layout_above="@+id/layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
注意::我要给
background color
和specific height
LinearLayout 2
了解您的理解.
Note : I am giving
background color
andspecific height
toLinearLayout 2
for your Understandment.
输出:
正常屏幕
键盘打开屏幕.
请参见上面我制作的图像Red Mark
,该属性会导致问题,否则一切正常.
see the upper Image I make Red Mark
that property create the problem otherwise every thing is work fine.
这篇关于Android软键盘仅浮动特定布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!