This is my code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/bgImage"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:contentDescription="@string/todo"
android:scaleType="fitXY"
android:src="@drawable/default_wallpaper" />
<LinearLayout
android:id="@+id/mainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/title"
android:orientation="vertical" >
<ListView
android:id="@+id/in"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@android:color/transparent"
android:cacheColorHint="@android:color/transparent"
android:divider="@android:color/transparent"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:orientation="horizontal" >
<EditText
android:id="@+id/edit_text_out"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:layout_weight="1"
android:inputType="none" />
<Button
android:id="@+id/button_send"
android:layout_width="70dp"
android:layout_height="fill_parent"
android:text="@string/send"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
In this when I tap on EditText
soft keyboard opens but my ImageView
is shrinking.
I used android:windowSoftInputMode="adjustPan"
in manifest file but by using this it will push up whole activity upper side but I want ImageView as it is and when keyboard is open ImageView is cut from bottom not from top as in WhatsApp
application.
Any help will appreciate. Thank you ..
remove the parent layout (the
RelativeLayout
) and make theLinearLayout
containing the dialog box only, the parent! plus, addandroid:windowSoftInputMode="stateVisible|adjustResize"
to theAndroidManifest.xml
I had a similar issue in which a custom View -
ParallaxBackground
- that I've adapted was supposed to act as a background image with a parallax effect driven by the scroll of aViewPager
in the same activity.In other words, I have a View that displays an image with a width slightly larger than the screen's and when the user scrolls along the
ViewPager
, the image in theParallaxBackground
scrolls a little as well.Now in my case, I had some EditTexts inside my ViewPager's Fragments and when the user clicked on them, causing the soft keyboard to show up, the ParallaxBackground (and consequently, the background image) would be re-sized and squeezed "against my will".
So I added a
boolean isBackground
, twoint
s forfixedWidth
andfixedHeight
and overrode my View'sonMeasure()
like so:I know this is not a "beautiful" solution but, even though my answer is not 100% related to your problem, you might want to try extending the
ImageView
class and overridingonMeasure
.Then, in your
onCreate
method you can setisBackground
to true and givefixedWidth
andfixedHeight
the values for your measured screen width and height.Add background image from Java not from XML:
In manifest add
The state hidden can written as per requirement if you have to hide the keyboard on opening of screen