Android Soft Keyboard Float Only Specific Layout
Solution 1:
as you can say this is not work
android:windowSoftInputMode="adjustPan|adjustResize"
just change it this
android:windowSoftInputMode="stateHidden"
and one more thing in your below layout
<RelativeLayoutxmlns: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--><LinearLayoutandroid: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"><EditTextandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="5"
/><ImageButtonandroid: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><LinearLayoutandroid: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>
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.
So Now that look like this
<LinearLayout
android:id="@+id/layout1"
android:layout_above="@+id/layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
Note : I am giving
background color
andspecific height
toLinearLayout 2
for your Understandment.
Output :
Normal Screen
KeyBoard Open Screen.
ImProve :
see the upper Image I make Red Mark
that property create the problem otherwise every thing is work fine.
Solution 2:
Please use this, and tell me if you find any difficulties
<?xml version="1.0" encoding="utf-8"?><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"><!--some stuff here--><ScrollViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"><LinearLayoutandroid:id="@+id/layout1"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_above="@+id/layout2"android:layout_alignParentBottom="true"android:orientation="horizontal"><EditTextandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="5" /><ImageButtonstyle="@style/Base.Widget.AppCompat.Button.Borderless"android:layout_width="50dp"android:layout_height="50dp"android:layout_marginLeft="5dp"android:scaleType="fitStart"android:src="@drawable/ic_menu_send" /></LinearLayout></ScrollView><LinearLayoutandroid:id="@+id/layout2"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:orientation="horizontal"><!--some stuff here--></LinearLayout></RelativeLayout>
Solution 3:
Use different themes for both the layouts.
such as: One theme refers to adjustPan for windowSoftInputMode attribute.
and another theme refers to adjustResize for windowSoftInputMode attribute.
Solution 4:
The fastest way is hide the layouts when soft keyboard is enable and show them again when the soft keyboard is disabled (layout2
on the xml)
Remove this Line as well
android:windowSoftInputMode="adjustPan|adjustResize"
it will work , this is just a simple way , I'm still searching for you
Solution 5:
put this line in your manifest file.
android:windowSoftInputMode="stateHidden"
Post a Comment for "Android Soft Keyboard Float Only Specific Layout"