質問

I tried to do a keyboard, just like the original Android keyboard. The keys on my keyboard are just simple buttons with an image as background. I noticed that it's much harder to type on my keyboard compared to the original one. It seems there is such thing as a tolerance:

http://i.imgur.com/fdMgaPX.png

If you are hitting the red point you will get an A. If you are hitting the blue point you will get a U or a J. There is literally no point you can hit without writing a letter. On my keyboard this is happens a lot, although it looks the same and the distances between the keys are equal. Does anyone know how to get to this or has anyone further informations about this function ?

Thanks!

正しい解決策はありません

他のヒント

It depends if you used the Button class for your keys. If so, there is no way to define what you call tolerance.

To avoid that, I'd create a class Key extending view or TextView. It would be less simple because you would have to define a background yourself, a font size; but it will be way more flexible, because you could create a custom hitbox a bit smaller than the button (and defined by a Rect). For instance, your button size less a margin of 5dp.

Then in the onTouchEvent, i'd check if the finger position is inside the hitbox. If it's not, simply return to the caller.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top