views:

374

answers:

2

Hi,

I have a layout which has one large EditText view at the top + a bunch of buttons at the bottom. The EditText is made to shrink and expand when the ime is activated/deactivated by using adjust_resize. The buttons at the bottom are pushed up above the ime.

I would like to hide these buttons when the ime displays, to provide enough space for the EditText view.

I have so far tried the following:

  • subclassed EditText and provided the activity the option to register a callback on the view's OnSizeChanged.

  • Used this callback to change the visibility of the buttons (actually the layout container) to GONE.

This work OK and does hide the buttons when the ime pops up. However, the EditText does not expand into the new available space. Furthermore, when the ime is disposed off, the EditText field is now bigger than it was originally, pushing (the now showing) buttons outside the screen.

I should also add that when typing the first letter into the view, and the ime displays the word options, the screen is redrawn and the EditText fills the vacant space.

Any ideas on how to get this to work? Or even better, is there a simpler solution to my requirement?

Thanks...

NB: In my view, scrolling is not a good option.

A: 

Have you tried to call myView.invalidade() ?

I was using the GONE property, but then changed to button.setVisibility(View.INVISIBLE); because I don't have any other stuff on my screen.

on the adjust_resize, you will need to check again when the keyboard has gone and show the buttons again.

Eduardo Aquiles
Thanks @Eduardo.I have tried myView.invalidade(). No luck.I need to use GONE as I want the space occupied by the buttons.I do already check and change visibility to VISIBLE when the keyboard has gone. I have described the outcome.Thanks again.
Ofer Ronen
A: 

I got this to work by changing the above method a bit:

  • Wrapped the entire layout with a FrameLayout

  • subclassed the FrameLayout and provided the activity the option to register a callback on the layout's OnMeasure

This gives the activity a chance to change visibility of views before these are measured.

I would still be very happy to hear about simpler solutions, especially in regards to figuring out whether the keyboard is currently visible or not. (dumpsys window shows this information. Can we easily get to it?)

Ofer Ronen