title: Android keyboard set to a custom position on screen
body: <p>I want to create a custom Android keyboard. The requirements are quite simple:</p>
  <ol>
  <li>The keyboard should not cover the full width of the screen.</li>
  <li>The keyboard should be located to the bottom right corner of the screen.</li>
  </ol>
  <p>I have managed to achieve the first requirement by changing the layout width to <code>android:layout_width=&quot;wrap_content&quot;</code>. Now the keyboard is exactly how I want it but the problem is that it is located to the bottom left corner of the screen as shown below.
  <a href="https://i.stack.imgur.com/1Uqkd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1Uqkd.jpg" alt="enter image description here" /></a></p>
  <p>Is there any way that I can move it to the right end of the bottom section of the screen?</p>
  <p>Please find below my code.</p>
  <p>Here is my layout xml file:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;android.inputmethodservice.KeyboardView
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:id=&quot;@+id/keyboard_view&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:keyPreviewLayout=&quot;@layout/key_preview&quot;
      android:layout_alignParentBottom=&quot;true&quot;
      android:background=&quot;@color/black&quot;&gt;
  &lt;/android.inputmethodservice.KeyboardView&gt;
  </code></pre>
  <p>This is my keyboard layout file:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;Keyboard xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:keyWidth=&quot;50dp&quot;
      android:horizontalGap=&quot;0dp&quot;
      android:verticalGap=&quot;0dp&quot;
      android:keyHeight=&quot;40dp&quot;&gt;
  
      &lt;Row&gt;
          &lt;Key android:codes=&quot;45&quot; android:keyLabel=&quot;-&quot;/&gt; 
          &lt;Key android:codes=&quot;47&quot; android:keyLabel=&quot;/&quot;/&gt;
          &lt;Key android:codes=&quot;120&quot; android:keyLabel=&quot;x&quot;/&gt;
      &lt;/Row&gt;
  
      &lt;Row&gt;
          &lt;Key android:codes=&quot;55&quot; android:keyLabel=&quot;7&quot;/&gt;
          &lt;Key android:codes=&quot;56&quot; android:keyLabel=&quot;8&quot;/&gt;
          &lt;Key android:codes=&quot;57&quot; android:keyLabel=&quot;9&quot;/&gt;
      &lt;/Row&gt;
  
      &lt;Row&gt;
          &lt;Key android:codes=&quot;52&quot; android:keyLabel=&quot;4&quot;/&gt;
          &lt;Key android:codes=&quot;53&quot; android:keyLabel=&quot;5&quot;/&gt;
          &lt;Key android:codes=&quot;54&quot; android:keyLabel=&quot;6&quot;/&gt;
      &lt;/Row&gt;
  
      &lt;Row&gt;
          &lt;Key android:codes=&quot;49&quot; android:keyLabel=&quot;1&quot;/&gt;
          &lt;Key android:codes=&quot;50&quot; android:keyLabel=&quot;2&quot;/&gt;
          &lt;Key android:codes=&quot;51&quot; android:keyLabel=&quot;3&quot;/&gt;
      &lt;/Row&gt;
  
      &lt;Row&gt;
          &lt;Key android:keyOutputText=&quot;mm &quot; android:keyLabel=&quot;mm&quot;/&gt;
          &lt;Key android:codes=&quot;48&quot; android:keyLabel=&quot;0&quot;/&gt;
          &lt;Key android:codes=&quot;46&quot; android:keyLabel=&quot;.&quot;/&gt;
      &lt;/Row&gt;
  &lt;/Keyboard&gt;
  </code></pre>
  <p>And this is my manifest:</p>
  <pre><code>&lt;activity
      android:name=&quot;com.example.customkeyboard.MainActivity&quot;
      android:label=&quot;@string/app_name&quot;
      android:theme=&quot;@style/Theme.customkeyboard.NoActionBar&quot;&gt;
      &lt;intent-filter&gt;
          &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
  
          &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
      &lt;/intent-filter&gt;
  &lt;/activity&gt;
  </code></pre>