android default keyboard layout styling - android

I am wanting to alter the default (whatever is on your device's) keyboard, so that the colors displayed reflect my apps overarching theme better. for example white background, light blue keys, that go dark blue when pressed.
Using this tutorial I have created a custom Keyboard and am able to change the keybackground.xml to adjust the colors of keys on a KeyboardView etc.
<android.inputmethodservice.KeyboardView
android:id="#+id/keyboardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:visibility="gone"
android:keyBackground="#drawable/keybackground"/>
what I am looking for is to apply this style to the default keyboard used by the device, failing that i have also looked for a copy of the keyboard layout xml so i can create a fully custom one with default key layout.
one possible method i have contemplated is replacing the following line (explained in the tutorial link).
mKeyboardView.setKeyboard(new Keyboard(mHostActivity, layoutid));
with another method of instantiating/getting default Keyboard.
Edit
I only require this keyboard to be displayed within my application.

You cannot change the colors of any of the installed keyboards (default or not), though some may allow you to create themes for them as a kind of extension but it would be something the user would install separately from your app. Keyboard apps are separate apps from yours and Android doesn't give you direct access to their layouts. You can create your own keyboard app of course, but this wouldn't make sense to do this in your case (as you're only after customizing colors for matching your app).
Additionally, it would be bad UX if each app changed the keyboard colors. Presumably, the user has picked a keyboard and theme that suits his/her visual needs, so it would be annoying if it changed between apps (imagine if you are a color blind user and an app changes the keyboard to colors you can't distinguish so you couldn't see what is on the keys anymore!).

You cannot do what you are planning to do in android, as it would be a massive security hole. Your app cannot change the default keyboard. What you can do is, make a new custom keyboard style and add it as a choice for the user. The user will have to go to settings->keyboard and select your keyboard. You will have to implement InputMethodService. Be warned though, its not a easy task. A lot of effort goes into it.

If you just want to add the keyboard to your application, add the keyboardview to your layout with visibility:gone. When the user clicks on an edittext field, consume the event going to the default keyboard and show your keyboard instead. Keep track of the keys pressed and append them wherever you need. Don't forget to hide your keyboard when the user clicks off the edittext field.

Related

Is there a way to show numeric keypad of android but with only selected numbers?

Is there a way to show numeric keypad of android but with only selected numbers?
Like i want to only show the numbers 2,4,6,8..all other numbers and signs should be blocked.
is there a way to do that in android?
Not really. I believe that you have the following options:
Create a custom keyboard
The most important downside is that each of your users would have to select your keyboard from system settings as the default.
Create a view, which looks like a keyboard
Probably the best approach, but the 'keyboard' most likely won't look like the native one.
Handle only the desired keys and ignore other.
If you can show all buttons and handle only a few of them - do that.
From the docs, there is a XML Attribute that should do the trick, but I have not tested it:
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/yourEditTextId"
android:digits="2468"
android:inputType="number" />
The XML Attribute digits, which is inherited from TextView, is described as follows:
If set, specifies that this TextView has a numeric input method and that these specific characters are the ones that it will accept. If this is set, numeric is implied to be true. The default is false.

Android: Pull out emoji keyboard on button press

I know that you can specify a short message input type in order to turn the enter key of the keyboard into an emoji button and pressing it will show up the emoji list but what i want to do is open up the emoji list programatically from a button. Is this possible?
There is no functionality to add tabs to any generic keyboard. Certain keyboards may support it, but it isn't a common feature. You could write your own fully custom keyboard, but that's a lot of work and will piss off many users.
Also, I'm not sure what you mean about by like in hangouts. I use hangouts- it doesn't do anything odd with my keyboard. It stays as Swype, there's no special emoji tab. It may be a feature of your favorite keyboard based on the input type (I assume both use input type textShortMessage). But it isn't a generic feature.
See Link Android Keyboard with Emoji
Thanks and enjoy...

Android Keyboard with Emoji

So I want to have a keyboard in my app that has emoji just like Whatsapp or Hangouts. How can I do that? I want to leave my key keyboard as it is I just want to add tabs to put emojis. I would think it would be easily supported by the soft keyboard but I can find nothing so far. Anyone could tell how to do it?
UPDATE:
The keyboard with emoji is included in Android KitKat and can be accessed by long pressing the new line button in the keyboard. The Hangouts keyboard however has the emoji icon visible instead of the "new line" key. If someone knows how to make this the default (either in layout or programmatically) I will take that as the correct answer.
As #dbar pointed out, the answer is:
android:inputType="textShortMessage"
But in my case, I was already using textMultiLine, so I had to use the both of them together:
android:inputType="textMultiLine|textShortMessage"
Looks like this:
I'm not sure about the Exact android version, but this should work only on Android 4.1 and above
Finally the answer was:
android:inputType="textShortMessage"
The new line key becomes a key to take out the emoji keyboard. The only quibble is the 'new line' key from the keyboard disappears with this configuration (before you could long press to choose between emoji/new line but now it's only emoji).
In Google Hangout, the emoji button is not on the keyboard (at least on my phone which is already using a third party keyboard), it's inside of the TextEdit box, and so it's part of the application itself (Gabe, I'm talking about the latest Google Hangout on top of KitKat with emoji support, all the current screenshots I found of Google Hangout do not show what I'm seeing on my phone, so this must be a very recent feature).
This is actually pretty easy to do, placing an ImageButton to the right of a TextView inside a RelativeLayout (the RelativeLayout which is made to look like a TextView with a custom background).
Then, it's just a matter of hiding the keyboard when clicking on that ImageButton and replacing it with a panel full of emojis when that happens (like in this open source emoji android keyboard, which is under a creative commons non-commercial license).
There is no functionality to add tabs to any generic keyboard. Certain keyboards may support it, but it isn't a common feature. You could write your own fully custom keyboard, but that's a lot of work and will piss off many users.
Also, I'm not sure what you mean about by like in hangouts. I use hangouts- it doesn't do anything odd with my keyboard. It stays as Swype, there's no special emoji tab. It may be a feature of your favorite keyboard based on the input type (I assume both use input type textShortMessage). But it isn't a generic feature.

android add buttons on top of softkeyboard

I want to add some buttons on top of the soft keyboard (Enter and Cancel). Is there a nice way to do this or do I have to detect the keyboard being shown and add the buttons into my view?
I can't see the logic your trying to apply here.
if you add buttons above your keyboard then you lose some areas in your keyboard (for example you cant press on q w s a).
I think you should look into creating your own custom keyboard.
maybe this will help
android app specific soft keyboard
Jason
You won't be able to do this, and with good reason. If apps could modify an existing input method like this, they could trivially log all keystrokes on your device without you knowing. If you've ever installed a custom input method, you'll see a big warning that using it means trusting it not to log your keystrokes, and the functionality you're after would totally circumvent that protection.

android app specific soft keyboard

Is there a way to create an app specific soft keyboard on Android? After reading about InputMethodService docs and checking out alternative keyboard apps out there, I figure the alternate keyboard can only be configured for system wide usage (through Settings -> Locale and Text).
If the answer to above question is no, then is there at least a way to load a custom dictionary and override the default dictionary of the system keyboard (only when my app is in use)? That will help in giving very relevant suggestions to the user when he has only tapped couple of keys.
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.
The Android Nethack application has a complete and clear source code example of how to create a custom keyboard for an application, how to display it on screen and how to define multiple keyboard layouts. It contains pretty much everything you need to know.
It is by far the best example I have seen.
http://code.google.com/p/nethack-android/

Categories

Resources