How do I make my own keyboard for an app in androi

2019-02-26 02:39发布

I am currently working on an app that requires a keyboard in a different language (Specifically Hebrew).

The problem is that I don't know where to begin. I don't want the user to have to go onto an app store, and install a separate app that has more languages in it just to use my app.

I only want the keyboard to be available in my app (i.e. it shouldn't effect anything outside my specific app). The way I am doing it right now is to create it as part of the main layout, and just make it visible whenever the user clicks on the Edit Text.

The problem with this approach is I can't get the size of it to readjust. I had originally tried using 2 different layouts (one in the res/layout folder, and one in the res/layout-lnd folder), but this caused different problems in my app, making it slower.

I am wondering 2 things, either of which should work.

  1. How would I create the layout for the keyboard to readjust.
  2. How would I make a keyboard correctly.

Here is the XML code that I am using specifically pertaining to the keyboard:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  android:visibility="gone"
  android:background="@color/puzzle_dark"  
  android:id="@+id/hebrwKeyboardView"  
  android:layout_width="fill_parent"  
  android:layout_height="146dip"  
  android:layout_gravity="right|center_vertical|center_horizontal|bottom"  
  android:fitsSystemWindows="true"  
  android:clipChildren="false"  
  android:orientation="vertical" >  
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  android:layout_width="wrap_content"  
  android:layout_height="145dip"  
  android:clipChildren="false"  
  android:layout_gravity="center_vertical|center_horizontal|bottom"  
  android:fitsSystemWindows="true"  
  android:orientation="horizontal" >  
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  android:layout_width="fill_parent"  
  android:layout_height="145dip"  
  android:clipChildren="false"  
  android:layout_gravity="center_vertical|center_horizontal|bottom"  
  android:fitsSystemWindows="true"  
  android:orientation="vertical" >  
  <TableRow android:layout_width="fill_parent"  
  android:layout_height="fill_parent"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:fitsSystemWindows="true"  
  android:clipChildren="false"  
  android:orientation="horizontal"  
  android:stretchColumns="true">  
  <LinearLayout   
  android:baselineAligned="true"  
  android:layout_width="fill_parent"  
  android:layout_gravity="center"  
  android:layout_height="fill_parent"  
  android:fitsSystemWindows="true"  
  android:clipChildren="false"  
  android:orientation="horizontal">  
  <Button  
  android:id="@+id/KoofButton"  
  android:layout_width="wrap_content"  
  android:layout_height="35dip"  
  android:text="@string/Koof"  
  android:layout_gravity="center"  
  android:fitsSystemWindows="true"  
  android:ellipsize="marquee"/>  
  <Button  
  android:soundEffectsEnabled="true"  
  android:id="@+id/raishButton"  
  android:layout_width="wrap_content"  
  android:layout_height="35dip"  
  android:text="@string/Raish"  
  android:layout_gravity="center_horizontal"  
  android:fitsSystemWindows="true"  
  android:ellipsize="marquee"/>  
  <Button  
 android:soundEffectsEnabled="true"  
  android:id="@+id/alephButton"  
  android:layout_gravity="center_horizontal"  
  android:layout_width="wrap_content"  
  android:layout_height="35dip"  
  android:text="@string/Alef"  
  android:fitsSystemWindows="true"  
  android:ellipsize="marquee"/>  
  <Button  
android:soundEffectsEnabled="true"  
  android:id="@+id/tetButton"  
  android:layout_width="wrap_content"  
  android:layout_gravity="center_horizontal"  
  android:layout_height="35dip"  
  android:text="@string/Tet"  
  android:fitsSystemWindows="true"  
  android:ellipsize="marquee"/>  
  <Button  
android:soundEffectsEnabled="true"  
  android:id="@+id/vuvButton"  
  android:layout_width="wrap_content"  
  android:layout_height="35dip"  
  android:layout_gravity="center_horizontal"  
  android:text="@string/Vuv"  
  android:fitsSystemWindows="true"  
  android:ellipsize="marquee"/>  
  <Button  
android:soundEffectsEnabled="true"  
  android:id="@+id/nunSophitButton"  
  android:layout_width="wrap_content"  
  android:layout_height="35dip"  
  android:layout_gravity="center_horizontal"  
  android:text="@string/NunSofit"   
android:fitsSystemWindows="true"   
android:gravity="fill"   
android:ellipsize="marquee"/>  
  <Button  
 android:soundEffectsEnabled="true"  
  android:id="@+id/memSofitButton"  
  android:layout_width="wrap_content"  
  android:layout_gravity="center_horizontal"  
  android:layout_height="35dip"  
  android:text="@string/MemSofit"  
  android:fitsSystemWindows="true"  
  android:ellipsize="marquee"/>  
  <Button  
android:soundEffectsEnabled="true"  
  android:id="@+id/payButton"  
  android:layout_width="wrap_content"  
  android:layout_height="35dip"
  android:text="@string/Pay"  
  android:fitsSystemWindows="true"  
  android:layout_gravity="center_horizontal"  
  android:ellipsize="marquee"/>  
  </LinearLayout>  
  </TableRow>  
  <TableRow android:layout_width="fill_parent"  
  android:layout_height="fill_parent"  
  android:clipChildren="true"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:fitsSystemWindows="true"  
  android:orientation="horizontal">  
  <RelativeLayout android:layout_width="fill_parent"  
  android:clipChildren="true"  
  android:layout_height="fill_parent"  
  android:layout_gravity="center_horizontal|center"  
  android:gravity="bottom"  
  android:orientation="horizontal">  
  <Button  
  android:layout_alignWithParentIfMissing="true"  
 android:soundEffectsEnabled="true"  
  android:id="@+id/shinButton"  
  android:layout_width="wrap_content"  
  android:layout_centerHorizontal="true"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:layout_height="35dip"  
  android:text="@string/Shin"  
  android:layout_alignParentLeft="true"  
  android:fitsSystemWindows="true"
  />  
  <Button  
  android:layout_centerHorizontal="true"  
 android:soundEffectsEnabled="true"  
 android:layout_toRightOf="@id/shinButton"  
  android:id="@+id/dalidButton"  
  android:layout_width="wrap_content"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:layout_height="35dip"  
  android:text="@string/Dalid"  
  android:layout_alignWithParentIfMissing="true"  
  android:fitsSystemWindows="true"
  />  
  <Button  
  android:layout_alignWithParentIfMissing="true"  
  android:layout_centerHorizontal="true"  
android:soundEffectsEnabled="true"  
  android:id="@+id/gimleButton"  
  android:layout_toRightOf="@id/dalidButton"  
  android:layout_width="wrap_content"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:layout_height="35dip"  
  android:text="@string/Gimle"  
  android:fitsSystemWindows="true"
  />  
  <Button  
  android:layout_alignWithParentIfMissing="true"  
  android:layout_centerHorizontal="true"  
android:soundEffectsEnabled="true"  
  android:id="@+id/chufButton"  
  android:layout_toRightOf="@id/gimleButton"  
  android:layout_width="wrap_content"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:layout_height="35dip"  
  android:text="@string/Chuf"  
  android:fitsSystemWindows="true"
  />  
  <Button  
  android:layout_alignWithParentIfMissing="true"  
  android:layout_centerHorizontal="true"  
android:soundEffectsEnabled="true"  
  android:id="@+id/ieyinButton"  
  android:layout_toRightOf="@id/chufButton"  
  android:layout_width="wrap_content"  
  android:layout_height="35dip"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:text="@string/Ieyin"  
  android:fitsSystemWindows="true"
  />  
  <Button  
  android:layout_alignWithParentIfMissing="true"  
  android:layout_centerHorizontal="true"  
android:soundEffectsEnabled="true"  
  android:id="@+id/yudButton"  
  android:layout_toRightOf="@id/ieyinButton"  
  android:layout_width="wrap_content"  
  android:layout_height="35dip"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:text="@string/Yud"  
  android:fitsSystemWindows="true"
  />  
  <Button  
  android:layout_alignWithParentIfMissing="true"  
  android:layout_centerHorizontal="true"  
  android:soundEffectsEnabled="true"  
  android:id="@+id/chetButton"  
  android:layout_toRightOf="@id/yudButton"  
  android:layout_width="wrap_content"  
  android:layout_height="35dip"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:text="@string/Chet"  
  android:fitsSystemWindows="true"
  />  
  <Button  
  android:layout_alignWithParentIfMissing="true"  
  android:layout_centerHorizontal="true"  
android:soundEffectsEnabled="true"  
  android:id="@+id/lamidButton"  
  android:layout_toRightOf="@id/chetButton"  
  android:layout_width="wrap_content"  
  android:layout_height="35dip"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:text="@string/Lamid"  
  android:fitsSystemWindows="true"
  />  
  <Button  
  android:layout_alignWithParentIfMissing="true"  
  android:layout_centerHorizontal="true"  
  android:soundEffectsEnabled="true"  
  android:id="@+id/chufSofitButton"  
  android:layout_toRightOf="@id/lamidButton"  
  android:layout_width="wrap_content"  
  android:layout_height="35dip"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:text="@string/ChufSofit"  
  android:fitsSystemWindows="true"
  />  
  <Button  
  android:layout_alignWithParentIfMissing="true"  
  android:layout_centerHorizontal="true"  
  android:soundEffectsEnabled="true"  
  android:id="@+id/paySofitButton"  
  android:layout_toRightOf="@id/chufSofitButton"  
  android:layout_width="wrap_content"  
  android:layout_height="35dip"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:text="@string/PaySofit"  
  android:fitsSystemWindows="true"
  />  
  </RelativeLayout>  
  </TableRow>  
  <TableRow android:layout_width="fill_parent"  
  android:layout_height="fill_parent"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:fitsSystemWindows="true"  
  android:orientation="horizontal">  
  <LinearLayout android:layout_width="fill_parent"  
  android:layout_height="fill_parent"  
  android:layout_gravity="center_horizontal|center"  
  android:gravity="bottom"  
  android:orientation="horizontal">  
  <Button  
 android:soundEffectsEnabled="true"  
  android:id="@+id/zionButton"  
  android:layout_width="wrap_content"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:layout_height="35dip"  
  android:text="@string/Zion"  
  android:fitsSystemWindows="true"
  />  
  <Button  
android:soundEffectsEnabled="true"  
  android:id="@+id/samichButton"  
  android:layout_width="wrap_content"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:layout_height="35dip"  
  android:text="@string/Samich"  
  android:fitsSystemWindows="true"
  />  
  <Button  
android:soundEffectsEnabled="true"  
  android:id="@+id/betButton"  
  android:layout_width="wrap_content"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:layout_height="35dip"  
  android:text="@string/Bet"  
  android:fitsSystemWindows="true"
  />  
  <Button  
android:soundEffectsEnabled="true"  
  android:id="@+id/heyButton"  
  android:layout_width="wrap_content"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:layout_height="35dip"  
  android:text="@string/Hey"  
  android:fitsSystemWindows="true"
  />  
  <Button  
android:soundEffectsEnabled="true"  
  android:id="@+id/nunButton"  
  android:layout_width="wrap_content"  
  android:layout_height="35dip"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:text="@string/Nun"  
  android:fitsSystemWindows="true"
  />  
  <Button  
android:soundEffectsEnabled="true"  
  android:id="@+id/memButton"  
  android:layout_width="wrap_content"  
  android:layout_height="35dip"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:text="@string/Mem"  
  android:fitsSystemWindows="true"
  />  
  <Button  
android:soundEffectsEnabled="true"  
  android:id="@+id/tzadiButton"  
  android:layout_width="wrap_content"  
  android:layout_height="35dip"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:text="@string/Tzadi"  
  android:fitsSystemWindows="true"
  />  
  <Button  
android:soundEffectsEnabled="true"  
  android:id="@+id/tuffButton"  
  android:layout_width="wrap_content"  
  android:layout_height="35dip"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:text="@string/Tuff"  
  android:fitsSystemWindows="true"
  />  
  <Button  
  android:soundEffectsEnabled="true"  
  android:id="@+id/tzadiSofitButton"  
  android:layout_width="wrap_content"  
  android:layout_height="35dip"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:text="@string/TzadiSofit"  
  android:fitsSystemWindows="true"
  />  
  </LinearLayout>  
  </TableRow>  
  <TableRow android:layout_width="fill_parent"  
  android:layout_height="fill_parent"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:fitsSystemWindows="true"  
  android:orientation="horizontal">  
  <LinearLayout android:layout_width="fill_parent"  
  android:layout_height="fill_parent"  
  android:layout_gravity="center_horizontal|center"  
  android:gravity="bottom"  
  android:orientation="horizontal">  
  <Button  
android:soundEffectsEnabled="true"  
  android:id="@+id/hebrewBackButton"  
  android:layout_width="wrap_content"  
  android:layout_height="35dip"  
  android:layout_gravity="right"  
  android:fitsSystemWindows="true"  
   android:text="&lt;--"/>  
  <Button  
android:soundEffectsEnabled="true"  
  android:id="@+id/hebrewSpaceButton"  
  android:layout_width="150dip"  
  android:layout_height="35dip"  
  android:layout_gravity="center_horizontal|center_vertical|center"  
  android:text=""  
  android:fitsSystemWindows="true"
  />  
  <Button  
android:soundEffectsEnabled="true"  
  android:id="@+id/hebrewDoneButton"  
  android:layout_width="wrap_content"  
  android:layout_height="wrap_content"  
  android:layout_gravity="right"  
  android:text="Done"  
  android:fitsSystemWindows="true"
  />  
  </LinearLayout>  
  </TableRow>  
</TableLayout>
</TableLayout>
</FrameLayout>`

Here is a picture of what it looks like right now in portrait and landscape:
enter image description here

enter image description here

0条回答
登录 后发表回答