I have a background image on my layout's outer-most LinearLayout. I simply do the following:
android:background="@drawable/home_background"
This stretches the image to the dimensions of my phone's screen (or more accurately, the dimensions of the LinearLayout).
Unfortunately, when a user clicks an EditText and the virtual keyboard shows, the image squishes because the height of the LinearLayout has shrunken. How can I get this to not happen?
for those searching for what I was -- the auto attribute above is specifying a height, so if you put in a fixed height like in the code background-size: 100% 150px; then your image will stretch horizontally while maintaining the 150px dimension.
1 Answer. Show activity on this post. The 100% 100% background-size value means the background should stretch (100%) of the width of the element and (100%) of the height of the element. Have either of them set to auto , which will size the undefined dimension automatically, while preserving the images aspect ratio.
Using CSS, you can set the background-size property for the image to fit the screen (viewport). The background-size property has a value of cover . It instructs browsers to automatically scale the width and height of a responsive background image to be the same or bigger than the viewport.
in Androidmanifest in activity tag use:
<activity
...
android:windowSoftInputMode="adjustPan" >
</activity>
for more info you may check Android Developer reference at
http://developer.android.com/guide/topics/manifest/activity-element.html
good luck,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With