title: In Xamarin.Android, how to ensure SoftInput AdjustResize works correctly on Keyboard's up/down event?
body: <p>What we need to accomplish:</p>
  <ul>
  <li><p>As a user I want to see a picture with the maximum size on the screen, from the screen bottom to the header's bottom</p>
  </li>
  <li><p>When the keyboard goes up or down, the picture should resize itself so it is always fully visible using the maximum space.</p>
  </li>
  </ul>
  <p><a href="https://i.stack.imgur.com/AfDbH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AfDbH.png" alt="enter image description here" /></a></p>
  <p>I've accomplished that in a mini project by following these steps:</p>
  <p>1 - Add following attribute in Android.manifest.xml <strong>application property:</strong></p>
  <pre><code>android:windowSoftInputMode=&quot;adjustResize&quot;
  </code></pre>
  <p>2 - Adding this line of code in the <strong>MainActivity OnCreate</strong> event handler:</p>
  <pre><code>Window.SetSoftInputMode(SoftInput.AdjustResize);
  </code></pre>
  <p>3 - using this layout property in the <strong>ImageView</strong> object:</p>
  <pre><code>android:layout_weight=&quot;1&quot;
  </code></pre>
  <p>That works fine in a mini project but when I port that code to our real project it does not work. When the keyboard prompts, the picture and the header seems to be scrolled up.</p>
  <p><a href="https://i.stack.imgur.com/TY75q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TY75q.png" alt="enter image description here" /></a></p>
  <p>The image is not resized, the picture is not fully visible and the header is not visible at all.</p>
  <p>The main difference in the real project is that it uses MVVMCross and there is no MainActivity class. There is a MainApplication class which is declared as:</p>
  <pre><code>public class MainApplication : MvxAndroidApplication&lt;Setup, App&gt;
  </code></pre>
  <p>I can't add the Window.SetSoftInputMode there because it says: &quot;CS0120: An object reference is required for the non-static field, method, or property 'Window.SetSoftInputMode(SoftInput)'&quot;&quot;</p>
  <p>So I tried using it in the View Activity as follows:</p>
  <pre><code>[Activity(Label = &quot;PhotoCaptionView&quot;, WindowSoftInputMode = SoftInput.AdjustResize, ScreenOrientation = ScreenOrientation.Portrait, Theme = &quot;@style/IM.Theme.Main&quot;, LaunchMode = LaunchMode.SingleTask)]
  public class EditPostView : BaseIMActivity&lt;EditPostViewModel&gt; 
  protected override void OnCreate(Bundle bundle)
  {
      Window.SetSoftInputMode(SoftInput.AdjustResize);
      base.OnCreate(bundle);
  }
  </code></pre>
  <p>Notice that I am setting SoftInput.AdjustResize in two places, as a decorator and also inline.</p>
  <p>I also added the property in the Android manifest but nothing seems to make AdjustResize work.
  I don't know what else to try.</p>