How to display a text above a Soft Keyboard in Android -


i'm trying develop custom soft keyboard in android. reading it, couldn't find way display above, in top of soft keyboard, text. mean, try display number of keys pressed. instead of see "suggestions" soft keyboard, want "key pressed: x", "x" number changes when press new key.

for example, if type following sequence "qwert", in top of soft keyboard, should see "keys pressed: 5". if then, press "y", text must updated "keys pressed: 6".

i've implemented logic behind this. mean, i'm being able count numbers of keys pressed, can't show want.

is there way it?

thanks!

edit: add xml files can take have @ point

keyboard.xml

<?xml version="1.0" encoding="utf-8"?> <android.inputmethodservice.keyboardview     xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/keyboard"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:layout_alignparentbottom="true"     android:keypreviewlayout="@layout/preview" /> 

this loaded keyboardview. then, have

previel.xml

<?xml version="1.0" encoding="utf-8"?> <textview     xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:gravity="center"     android:background="#ffff00"     android:textstyle="bold"     android:textsize="25sp"     /> 

the template keys. ,

keyboard.xml

<?xml version="1.0" encoding="utf-8"?> <keyboard xmlns:android="http://schemas.android.com/apk/res/android"     android:keywidth="10%p"     android:horizontalgap="0px"     android:verticalgap="0px"     android:keyheight="60dp"     >     <row>         <key android:codes="49" android:keylabel="1" android:keyedgeflags="left"/>         <key android:codes="50" android:keylabel="2"/>         <key android:codes="51" android:keylabel="3"/>         <key android:codes="52" android:keylabel="4"/>         <key android:codes="53" android:keylabel="5"/>         <key android:codes="54" android:keylabel="6"/>         <key android:codes="55" android:keylabel="7"/>         <key android:codes="56" android:keylabel="8"/>         <key android:codes="57" android:keylabel="9"/>         <key android:codes="48" android:keylabel="0" android:keyedgeflags="right"/>     </row>     <row>         <key android:codes="113" android:keylabel="q" android:keyedgeflags="left"/>         <key android:codes="119" android:keylabel="w"/>         <key android:codes="101" android:keylabel="e"/>         <key android:codes="114" android:keylabel="r"/>         <key android:codes="116" android:keylabel="t"/>         <key android:codes="121" android:keylabel="y"/>         <key android:codes="117" android:keylabel="u"/>         <key android:codes="105" android:keylabel="i"/>         <key android:codes="111" android:keylabel="o"/>         <key android:codes="112" android:keylabel="p" android:keyedgeflags="right"/>     </row>     <row>         <key android:codes="97" android:keylabel="a" android:keyedgeflags="left"/>         <key android:codes="115" android:keylabel="s"/>         <key android:codes="100" android:keylabel="d"/>         <key android:codes="102" android:keylabel="f"/>         <key android:codes="103" android:keylabel="g"/>         <key android:codes="104" android:keylabel="h"/>         <key android:codes="106" android:keylabel="j"/>         <key android:codes="107" android:keylabel="k"/>         <key android:codes="108" android:keylabel="l"/>         <key android:codes="35,64" android:keylabel="\# \@" android:keyedgeflags="right"/>     </row>     <row>         <key android:codes="-1" android:keylabel="caps" android:keyedgeflags="left"/>         <key android:codes="122" android:keylabel="z"/>         <key android:codes="120" android:keylabel="x"/>         <key android:codes="99" android:keylabel="c"/>         <key android:codes="118" android:keylabel="v"/>         <key android:codes="98" android:keylabel="b"/>         <key android:codes="110" android:keylabel="n"/>         <key android:codes="109" android:keylabel="m"/>         <key android:codes="46" android:keylabel="."/>         <key android:codes="63,33,58" android:keylabel="\? ! :" android:keyedgeflags="right"/>     </row>     <row android:rowedgeflags="bottom">         <key android:codes="44" android:keylabel="," android:keywidth="10%p"  android:keyedgeflags="left"/>         <key android:codes="47" android:keylabel="/" android:keywidth="10%p" />         <key android:codes="32" android:keylabel="space" android:keywidth="40%p" android:isrepeatable="true"/>         <key android:codes="-5" android:keylabel="del" android:keywidth="20%p" android:isrepeatable="true"/>         <key android:codes="-4" android:keylabel="done" android:keywidth="20%p" android:keyedgeflags="right"/>     </row> </keyboard> 

my keyboard template.

i used example code find here

as l-x recommended me, modified keyboard.xml. don't know if there better solution, works fine purpose.

this how implemented

keyboard.xml

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="vertical"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:layout_alignparentbottom="true">      <textview         android:id="@+id/keypressed"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:text=""         android:textsize="20dp"         android:textcolor="#ffffff"         android:background="#000000" />      <android.inputmethodservice.keyboardview         android:id="@+id/keyboard2"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:keypreviewlayout="@layout/preview" />  </linearlayout> 

now, see this.

![keyboard_photo ]1

thanks!


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -