title: EditText AdjustResize forcing content out of view
body: <p>I'm currently developing a simple Notes application where the user can input a title and the content of their note. What I am looking to achieve is that when the user clicks the note content (EditText) the soft keyboard comes up and only the note content EditText reduces in size (resizes) whilst everything else remains in the same position. </p>
  
  <p>My current implementation can be seen below:</p>
  
  <p>Manifest: </p>
  
  <pre><code>&lt;activity android:theme="@style/AppTheme"
          android:name=".AddActivity"
          android:label="@string/add_record"
          android:windowSoftInputMode="adjustResize"
          android:parentActivityName=".MainActivity"
          android:excludeFromRecents="true"/&gt;
  </code></pre>
  
  <p>XML - Add Activity</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/add_record"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:padding="20dp"&gt;
  
      &lt;EditText
          android:id="@+id/title_edittext"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:ems="10"
          android:hint="@string/enter_title"
          android:inputType="textCapSentences"
          android:textColor="@color/fontPrimary"
          android:theme="@style/EditTextCustomCursor"&gt;
  
          &lt;requestFocus /&gt;
      &lt;/EditText&gt;
  
      &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/modify_scrollview"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:fitsSystemWindows="false"
          android:isScrollContainer="false"
          android:fillViewport="true"&gt;
  
          &lt;EditText
              android:id="@+id/note_edittext"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:background="@null"
              android:ellipsize="end"
              android:gravity="top|left"
              android:hint="@string/enter_note"
              android:inputType="textCapSentences|textMultiLine"
              android:paddingLeft="5dp"
              android:scrollHorizontally="false"
              android:textColor="@color/fontPrimary"
              android:theme="@style/EditTextCustomCursor" /&gt;
      &lt;/ScrollView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Java - Add Activity</p>
  
  <pre><code>private int screenHeight;
  private int actionBarHeight = 350;
  private int keyboardHeight;
  </code></pre>
  
  <p>...</p>
  
  <pre><code>private void setupListeners() {
  
      final LinearLayout layout = (LinearLayout) findViewById(R.id.add_record);
      layout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
  
          @Override
          public void onGlobalLayout() {
              Rect r = new Rect();
              layout.getWindowVisibleDisplayFrame(r);
  
              screenHeight = layout.getRootView().getHeight();
              keyboardHeight = screenHeight - (r.bottom - r.top);
              Log.d("Keyboard Size", "Size: " + keyboardHeight);
  
          }
      });
  
      KeyboardVisibilityEvent.setEventListener(
              AddActivity.this,
              new KeyboardVisibilityEventListener() {
                  @Override
                  public void onVisibilityChanged(boolean isOpen) {
  
                      if (isOpen) {
                          Log.d("KB", "openKeyboard");
                          scrollView.setLayoutParams(new LinearLayout.LayoutParams(
                                  LinearLayout.LayoutParams.FILL_PARENT, screenHeight - actionBarHeight - keyboardHeight));
                      } else {
                          Log.d("KB", "closeKeyboard");
                          scrollView.setLayoutParams(new LinearLayout.LayoutParams(
                                  LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT));
                      }
                  }
              });
  }
  </code></pre>
  
  <p>This is using the Keyboard library (<a href="https://github.com/yshrsmz/KeyboardVisibilityEvent" rel="nofollow noreferrer">https://github.com/yshrsmz/KeyboardVisibilityEvent</a>) to detect when the keyboard is opened or closed. This works perfectly and the height / layout is adjusted just how I want it to look but only if the user clicks at the top of the EditText. If the user clicks at the bottom of the EditText (if they have entered a long note) then the whole layout gets pushed up leaving a large gap at the bottom of the page. </p>
  
  <p>Therefore, is there any way how wherever in the EditText / ScrollView the user clicks, for it to only adjust that one EditText in height and leave the other EditText in place at the top of the screen without pushing it and the SupportActionBar out of view? Also, the ScrollView is being used to achieve the vertical scrollbar on the right side of the screen - if this same behaviour can be achieved using just the EditText, then I would remove the ScrollView altogether.  </p>
  
  <p><strong>EDIT -</strong> Add Photos</p>
  
  <p>Image 1: Long note content (bottom of note content is at the bottom of the scrollView (which cannot be seen, until scrolled))</p>
  
  <p><a href="https://i.stack.imgur.com/1qYWt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1qYWt.png" alt="Clicking top half of note EditText"></a></p>
  
  <p>Image 2: Same note but clicking at the bottom, forces the top EditText and Support ActionBar out of view whilst leaving a gap at the bottom. </p>
  
  <p><a href="https://i.stack.imgur.com/c94TZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c94TZ.png" alt="Clicking bottom half of note EditText"></a></p>
  
  <p>Explanation: Where the F is highlighted (in Image 2) that is the bottom of the EditText / ScrollView so you can see the large gap created between the top of the soft keyboard and the bottom of the EditText / ScrollView</p>
  
  <p>Desired behaviour: Clicking anywhere in the bottom EditText should only resize that particular EditText to make room for the soft keyboard and ensure that this EditText is above the soft keyboard so the user can see what they are typing whilst the top EditText remains in the same position throughout. </p>