Setting the background of an Activity

后端 未结 3 1887
南旧
南旧 2020-12-04 01:15

In the onCreate() method of my Activity, I grab the outermost LinearLayout of the Activity\'s layout. I then check to see what the orientation of the phone is. If it is po

3条回答
  •  感动是毒
    2020-12-04 01:56

    Override the onConfigurationChange() method, since the changes in layout are handled with this method.

      @Override
        public void onConfigurationChanged(Configuration newConfig) {
                if(newConfig.orientation==Configuration.ORIENTATION_LANDSCAPE)
                {
                    //change of background 
                }
                else if(newConfig.orientation==Configuration.ORIENTATION_PORTRAIT)
                {
                    //change the background
                }
                        else
                        { //do nothing, this might apply for the keyboard }
    
    
              super.onConfigurationChanged(newConfig);
    
    
            }
    
    
        }
    

    and add this to your manifest

    
    

提交回复
热议问题