Android: Background image resize on keyboard pop up

后端 未结 12 925
伪装坚强ぢ
伪装坚强ぢ 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:38

    Just use in your onCreate() this code:

    protected void onCreate(Bundle savedInstanceState) {
    ...   
     getWindow().setBackgroundDrawableResource(R.drawable.your_image_resource);
    ...
    }
    

    and eliminate this line in your xml:

    android:background="@drawable/background"
    

    Read more at:

    http://developer.android.com/reference/android/view/Window.html

    0 讨论(0)
  • 2021-02-03 20:44

    Why don't you do like this

        <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:fillViewport="true"
            android:focusable="true"
            android:background="@drawable/background"
            android:focusableInTouchMode="true">
    
            <RelativeLayout
                android:id="@+id/relative"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:focusable="true"
                android:focusableInTouchMode="true"
        /**
                  Other stuff 
                */
        >
      </RelativeLayout>
      </ScrollView>
    
    0 讨论(0)
  • 2021-02-03 20:47

    I had faced the similar issue once, mine was solved by using the below properties in manifest use it where your activity is declared.

     android:windowSoftInputMode="stateHidden|adjustResize|adjustPan"
    
    0 讨论(0)
  • 2021-02-03 20:47

    i am using below view heirarchy and its working fine for me:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
    
        <ScrollView
            android:id="@+id/rfqItemsParentScrollView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical" >
    
    0 讨论(0)
  • 2021-02-03 20:48

    Hey can you please try adding this

    android:isScrollContainer="false" 
    

    in your ScrollView. It has solved my problem once. Might help u too.

    Also, add this to your activity in manifest.xml

    android:windowSoftInputMode="adjustPan"
    

    Hope it helps..!! :)

    0 讨论(0)
  • 2021-02-03 20:49

    You should use the adjustResize option for the windowSoftInputMode setting on the Activity in your AndroidManifest.xml file.

    0 讨论(0)
提交回复
热议问题