Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

android - How to force redraw of soft keyboard

I created a custom keyboard which doesn't resize correctly when the orientation changes. I've tried invalidateKeys(), and manually setting the size of all of the keys, but no joy.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I was having a simular problem with resizing my keyboardview's key height dynamically. To workaround the problem I did a couple of things:

1) Create a new class that extends the Keyboard class that defines a public getKeyHeight method and overrides the getHeight method. My prototype code:

public void setKeyHeight(int height) {
   super.setKeyHeight(height);
}

@Override
public int getHeight() {
   return getKeyHeight() * 3;
}

2) Defined a new method in my

double height_modifier = 1.5;

int height = 0;
for(Keyboard.Key key : mKeyboard.getKeys()) {
   key.height *= height_modifier;
   key.y *= height_modifier;
   height = key.height;
}
mKeyboard.setKeyHeight(height);

I hope this helps...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...