android app specific soft keyboard
If you just want a View that looks and acts like a soft keyboard, I did that in my SmallKeyboard class. You just need to extend android.inputmethodservice.KeyboardView and decide on layout. See the onKey and onText methods at the end of that file for the action taken when keys are pressed.
Instead of my keyboard model inner class, you could load it from XML if your key set is fairly constant.
Creating an application specific keyboard
Since it's a one-off thing and not meant as a separate app, You can simply use whatever method is easiest for you (The KeyboardView
method).
Try it out and make sure it's responsive and snappy. If it works, then simple and easy method would be my recommendation.
app specific keyboard
Yes, extend it is the best way to go. Wrap what you want to add. Create another keyboard and set it to that keyboard.
Open soft keyboard programmatically
I have used the following lines to display the soft keyboard manually inside the onclick event, and the keyboard is visible.
InputMethodManager inputMethodManager =
(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(
linearLayout.getApplicationWindowToken(),
InputMethodManager.SHOW_FORCED, 0);
But I'm still not able to open this while the activity gets opened, so are there any solution for this?
How can I implement special soft keyboard
Create XML like this for keyboard :
<?xml version="1.0" encoding="utf-8"?>
<com.YourKeyboardView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/keyboard"
style="@style/keyboard_1_style"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</com.YourKeyboardView>
And style is as below:
<style name="keyboard_1_style">
<item name="android:keyBackground">@drawable/k1_selector</item>
<item name="android:keyTextColor">#24B2E7</item>
<item name="android:background">@android:color/white</item>
<item name="android:keyPreviewLayout">@layout/k1_preview</item>
</style>
In which
<item name="android:keyBackground">@drawable/k1_selector</item>
is used to set background for key.
<item name="android:keyTextColor">#24B2E7</item>
is used for text color of key.
<item name="android:background">@android:color/white</item>
is used to set background of entire keyboard and
<item name="android:keyPreviewLayout">@layout/k1_preview</item>
is uesd to set preview of key.
Preview layout xml :
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="40sp"
android:textColor="@android:color/white"
android:gravity="center"
android:background="@drawable/neon_candidate_middle_pressed"/>
For spaces between keys use this.
And for android:background="@drawable/neon_candidate_middle_pressed"
it is background image which you want to show in preview of key.
Related Topics
Design Android Edittext to Show Error Message as Described by Google
Uploading Images to Server Android
How to Reference Style Attributes from a Drawable
Force an Android Activity to Always Use Landscape Mode
Permission Is Only Granted to System App
Error: No Resource Identifier Found for Attribute 'Adsize' in Package 'Com.Google.Example' Main.Xml
How to Set Margin of Imageview Using Code, Not Xml
Media Queries Not Behaving as Expected on Android
Android - Multiple Screen Support Issue
What Does Porterduff.Mode Mean in Android Graphics.What Does It Do
Why Does Contentresolver.Requestsync Not Trigger a Sync
What Is the Size of Actionbar in Pixels
Jelly Bean Datepickerdialog --- How to Cancel
Android Webview - Webpage Should Fit the Device Screen
Android Command Line Tools Sdkmanager Always Shows: Warning: Could Not Create Settings