p6majo
p6majo

Reputation: 287

Make some keys of the keyboard invisible

It is convenient to customize the keyboard available for users.

Depending on the position of the cursor, I want to show two different keyboards, similar to the ones shown in the pictures.

full keyboard

constraint keyboard

In the second keyboard some keys are omitted to prevent wrong input. How can it be achieved, that the displayed keys are at the same positions as they are on the full keyboard, ie the omitted keys are supposed to be "invisible" but not "gone". Unfortunately, I cannot find corresponding xml-attributes for the keys.

Upvotes: 0

Views: 544

Answers (2)

Yuma
Yuma

Reputation: 1

I hava a simple solution. Set you target key x or y property into a incorrect value.This key will be invalidated status .Code like that

override fun onDraw(canvas: Canvas?) {
    //keyboard.keys[index].x = -999
    keyboard.keys[index].y = -999
    super.onDraw(canvas)
    //do something
}

Upvotes: 0

James
James

Reputation: 3749

From what I can tell, you're saying that the 'up arrow' key is 'moving' over to the left side because you've got rid of the 'EE' key?

I think that you're just after android:horizontalGap that can be applied to each Keyboard.Key. I would create two layouts. The first is the top keyboard, and the second is essentially a tweaked version of the first, using the aforementioned android:horizontalGap to add padding. So when the event occurs that causes the switch, the Keyboard changes to the correct layout.

Upvotes: 1

Related Questions