title: Android custom soft keyboard - set keyboard width to match_parent (device screen width)
body: <p>I'd like to have a soft keyboard like image 2 with some more button.</p>
  
  <p>I'm following this example:
  <a href="https://android.googlesource.com/platform/development/+/master/samples/SoftKeyboard/" rel="nofollow noreferrer">https://android.googlesource.com/platform/development/+/master/samples/SoftKeyboard/</a></p>
  
  <p>But my problem is I dont know how to set the soft keyboard width to match its parent with setting keyWidth 15% -> The left side of my keyboard is empty like image 1.</p>
  
  <p>Can you help me out? Thanks,</p>
  
  <p>Class SoftKeyboard </p>
  
  <pre><code>public class SoftKeyboard extends InputMethodService 
      implements KeyboardView.OnKeyboardActionListener {
  
      private LatinKeyboardView mInputView; //public class LatinKeyboardView extends KeyboardView
  
      @Override public View onCreateInputView() {
          mInputView = (LatinKeyboardView) getLayoutInflater().inflate(
                  R.layout.input, null);
          mInputView.setOnKeyboardActionListener(this);
          setLatinKeyboard(mQwertyKeyboard);
          return mInputView;
      }
  
  
      @Override public void onInitializeInterface() {
          if (mQwertyKeyboard != null) {
              // Configuration changes can happen after the keyboard gets recreated,
              // so we need to be able to re-build the keyboards if the available
              // space has changed.
              int displayWidth = getMaxWidth();
              if (displayWidth == mLastDisplayWidth) return;
              mLastDisplayWidth = displayWidth;
          }
          mQwertyKeyboard = new LatinKeyboard(this, R.xml.qwerty);
          mSymbolsKeyboard = new LatinKeyboard(this, R.xml.symbols);
          mSymbolsShiftedKeyboard = new LatinKeyboard(this, R.xml.symbols_shift);
          mNumberKeyboard = new LatinKeyboard(this, R.xml.number);
      }
  
      //...
  }
  </code></pre>
  
  <p>R.layout.input.xml:</p>
  
  <pre><code>    android:id="@+id/keyboard"
      android:layout_alignParentBottom="true"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
  </code></pre>
  
  <p>R.xml.number.xml:</p>
  
  <pre><code>&lt;Keyboard
  android:keyWidth="15%p"
  android:horizontalGap="0px"
  android:verticalGap="0px"
  android:keyHeight="@dimen/key_height"
  android:layout_width="match_parent"&gt;
  
  &lt;Row&gt;
      &lt;Key android:codes="49" android:keyLabel="1" android:keyEdgeFlags="left"/&gt;
      &lt;Key android:codes="50" android:keyLabel="2"/&gt;
      &lt;Key android:codes="51" android:keyLabel="3"/&gt;
      &lt;Key android:codes="-5" android:keyIcon="@drawable/sym_keyboard_delete" android:keyEdgeFlags="right"
          android:isRepeatable="true"/&gt;
  &lt;/Row&gt;
  
  &lt;Row&gt;
      &lt;Key android:codes="52" android:keyLabel="4" android:keyEdgeFlags="left"/&gt;
      &lt;Key android:codes="53" android:keyLabel="5"/&gt;
      &lt;Key android:codes="54" android:keyLabel="6"/&gt;
      &lt;Key android:codes="28" android:keyLabel="RAZ" android:keyEdgeFlags="right"/&gt;
  &lt;/Row&gt;
  
  &lt;Row&gt;
      &lt;Key android:codes="55" android:keyLabel="7" android:keyEdgeFlags="left"/&gt;
      &lt;Key android:codes="56" android:keyLabel="8"/&gt;
      &lt;Key android:codes="57" android:keyLabel="9" android:keyEdgeFlags="right" /&gt;
  &lt;/Row&gt;
  
  &lt;Row android:rowEdgeFlags="bottom"&gt;
      &lt;Key android:codes="-3" android:keyIcon="@drawable/sym_keyboard_done" /&gt;
      &lt;Key android:codes="48" android:keyLabel="0"/&gt;
      &lt;Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
              android:keyWidth="47%p" android:keyEdgeFlags="right"/&gt;
  &lt;/Row&gt;
  &lt;/Keyboard&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/iigOQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iigOQ.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/vz4hj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vz4hj.png" alt="enter image description here"></a></p>