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

Categories

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

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...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...