Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Background image stretching

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?

like image 241
Andrew Avatar asked Dec 03 '10 23:12

Andrew


People also ask

How do I stretch an image horizontally in CSS?

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.

How do I stop my background image from stretching in HTML?

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.

How do I make the background image fit my screen size?

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.


1 Answers

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,

like image 119
Maher Abuthraa Avatar answered Sep 20 '22 08:09

Maher Abuthraa