I have a listview and the last list item contains EditText:
<RelativeLayout
android:id="@+id/contentLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="30dp"
android:orientation="vertical" >
<ImageView
android:id="@+id/test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/messageEditText"
android:layout_below="@+id/messageEditText"
android:layout_marginRight="14dp"
android:src="@drawable/test" />
<EditText
android:id="@+id/messageEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/sendImageButton"
android:ems="10"
android:gravity="top"
android:hint="@string/messageEditText"
android:inputType="textMultiLine"
android:minHeight="55dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" />
<ImageButton
android:id="@+id/sendImageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/messageEditText"
android:layout_alignParentRight="true"
android:layout_alignTop="@id/messageEditText"
android:adjustViewBounds="true"
android:maxHeight="55dp"
android:maxWidth="55dp"
android:padding="12dp"
android:scaleType="centerInside"
android:src="@drawable/sendmessage" />
</RelativeLayout>
Half of the EditText is hidden. I also can't scroll listview. Any solution?
Set an
android:softInputMode
attribute for your Activity element in your Manifest.See the Manifest documentation for a full list of valid values and their effect. The ones of particular interest to you will likely be
adjustPan
andadjustResize
.Disable the keyboard on window startup
I Had a similar issue, then i used
android:windowSoftInputMode="adjustResize|stateHidden"
as mentioned here.. It works very well for me..Solution was to set an
android:softInputMode
attribute toadjustResize
in Manifest and put layout(not list item layout) inside a ScrollView.From my early days as a Android Developer I struggled with the virtual keyboard. I am amazed that Android is still not giving an elegant and clear solution for this.
So here is the Workaround that will put this mess behind you. it will work without the ScrollView workaround or giving away your full screen flag.
compile'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:1.0.1'
android:windowSoftInputMode="adjustResize"
wrap your EditText with a vertical LinearLayout and add a View with Visibility of Gone:
calculate the screen size so you can calculate the height of the view that pushes the EditText:
This is the result: