Android: Background image resize on keyboard pop up

后端 未结 12 1082
伪装坚强ぢ
伪装坚强ぢ 2021-02-03 20:01

I am developing an application in which the background image get shrink on keyboard pop-up. My .xml is as follows :



        
12条回答
  •  天涯浪人
    2021-02-03 20:58

    You should move the android:background="@drawable/background" in an ImageView above ScrollView. When the keyboard pops up it effectivly makes the screen smaller, and having an image as background you have no control on how it is resized/cropped. So, assuming you want to have the image full width but keep the ascpect ratio try this:

    
    
        
    
        
                       
                /**
                Other stuff
                */
            
        
    
    

    You can try different android:scaleType values to achive your desired effect. If you want the image to be cropped from the top instead of the default middle crop, see here on how to achieve this, or try using this library

提交回复
热议问题