KeyboardView is deprecated in android


KeyboardView has been deprecated official by android team in API level 29 and i didn't able to find the alternative way for this. Please let me know if there any alternative?


From the docs here :


This class was deprecated in API level 29. This class is deprecated because this is just a convenient UI widget class that application developers can re-implement on top of existing public APIs. If you have already depended on this class, consider copying the implementation from AOSP into your project or re-implementing a similar widget by yourselves


This means that you have to create your own view with all the keys, which also means handling all the click events like enter, delete and switching keyboards eg. to symbols etc. by yourself.

Actually there are many ways to do it. But I will try to give you a simple idea, you will follow most of the steps that you used while using the deprecated KeyboardView:

First create your custom keyboard layout with android:layout_height="wrap_content", you can use any layout depending what is convenient for you like LinearLayout, RelativeLayout and Buttons for the keys. I used a GridLayout with Buttons.

Then create the subclass of InputMethodService as usual:

public class MyIMService extends InputMethodService implements View.OnClickListener { private static String TAG = "MyIMService"; @Override public View onCreateInputView() { View myKeyboardView = getLayoutInflater().inflate(R.layout.key_layout, null); Button btnA = myKeyboardView.findViewById(R.id.btnA); btnA.setOnClickListener(this); //ADD ALL THE OTHER LISTENERS HERE FOR ALL THE KEYS return myKeyboardView; } @Override public void onClick(View v) { //handle all the keyboard key clicks here InputConnection ic = getCurrentInputConnection(); if (v instanceof Button) { String clickedKeyText = ((Button) v).getText().toString(); ic.commitText(clickedKeyText, 1); } } }

The key_layout should contains all the keys can be any layout, I used a GridLayout which resembles a typical keyboard. For switching between symbols or numbers you should update the text of the buttons etc. As I said earlier you can try a different way of handling all the click events. But this should give you the basic idea.

That's it. You have to add this service in your manifest file as usual and also the other steps as usual. This should work now.



  • KeyboardView is deprecated in android
  • Make comments of VSCode start at column position 0
  • Use options set on apache camel direct endpoint
  • NoSuchMethodError using @Parcelize Annotation in Kotlin
  • Case expressions may only be nested to level 10
  • Jquery's Ajax Property For Asp.Net 2.0
  • Swift 3 - Passing data between a View Controller and after that to another 2
  • Tap Gesture on List View Items
  • Removing URL .php extension gives 404 error
  • Qt WebView and WebChannel over WebSockets in QML
  • R SparkR - equivalent to melt function
  • Error: packet sequence number wrong after upgrading RDS instance
  • Migrating MOSS 2007 from SQL 2000 to SQL 2005 [closed]
  • How to use template selector within a ContentPresenter in Windows 8.1
  • Working with codeception and laravel
  • Parallelization via JDBC - Pyspark - How does parallelization work using JDBC?
  • Background beacon detection and Notification (Both iOS and Android) for Eddystone beacon?
  • Get max bookings count in range
  • VB.NET and LINQ - Group by in a DataTable
  • Javascript / jQuery not executing in IE until the body of the page is moused over
  • How do I change the names of buttons on a message box?
  • Unity Resources.load() won't work with external dll
  • playing mp3 from nsbundle
  • Debugging php script timeout?
  • How to make Rss News Reader application in android …? [closed]
  • Set SelectedIndex of ListView in FlipView_SelectionChanged event
  • Thumbnails for mxml components in Flex
  • How to check if a database and tables exist in sql server in a vb .net project?
  • How to run chrome.tabs.insertCSS from the background page on each page?
  • java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/SpringDispatcher-ser
  • Can I read another applications memory?
  • Is there a better way for handling SpatialPolygons that cross the antimeridian (date line)?
  • How to call jQuery function in HTML returned by AJAX
  • How do I add a mouse over tooltip to an Image using .DrawImage()
  • VSTS work items list through REST API
  • How to warp text around image in iOS?
  • Bad automatic Triangulation with Mayavi for coloring a surface known only by its corner