Finalmente, scopro una soluzione per il mio problema, quindi voglio condividere per qualcuno forse avere lo stesso problema in futuro. Una breve descrizione del mio layout come segue:
<myRelativeLayout>
<topbar.../>
<myscrollView>
<linearLayout>
//all stuff controls:editview,textview,....
</linearLayout>
</myscrollView>
<bottombar.../>
ho creare classe personalizzata myRelativeLayout estendere RelativeLayout
public class myRelativeLayout extends RelativeLayout{
public interface OnRelativeLayoutChangeListener {
void onLayoutPushUp();
void onLayoutPushDown();
}
private OnRelativeLayoutChangeListener layoutChangeListener;
public myRelativeLayout(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int proposedheight = MeasureSpec.getSize(heightMeasureSpec);
final int actualHeight = getHeight();
if (actualHeight > proposedheight){
// Keyboard is shown
layoutChangeListener.onLayoutPushUp();
} else if(actualHeight < proposedheight){
// Keyboard is hidden
layoutChangeListener.onLayoutPushDown();
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
public void setLayoutChangeListener(OnRelativeLayoutChangeListener layoutChangeListener) {
this.layoutChangeListener = layoutChangeListener;
}
public OnRelativeLayoutChangeListener getLayoutChangeListener() {
return layoutChangeListener;
}
}
E nella mia attività, ho appena impostato setLayoutChangeListener per myRelativeLayout per nascondere il tasto in basso quando viene visualizzata la softkey e viene visualizzato il tasto in basso quando la tastiera nasconde:
myRlayout.setLayoutChangeListener(new OnRelativeLayoutChangeListener() {
@Override
public void onLayoutPushUp() {
// TODO Auto-generated method stub
myBottombar.setVisibility(View.GONE);//in my case i need to setVisibility(View.GONE) to bottombar in order for this bar is not displayed when softkeyboard show up.
}
@Override
public void onLayoutPushDown() {
// TODO Auto-generated method stub
myBottombar.setVisibility(View.VISIBLE);// redisplay myBottombar when keyboard is closed.
}
});
Non dimenticare set android: windowSoftInputMode = "adjustResize" per l'attività. Spero che questo utile per qualcuno abbia avuto lo stesso problema.
Ho lo stesso problema, ma non mi piace fare la codifica che hai fatto per "fingere" ... hmm – Ted
finora questa soluzione ha funzionato bene, ho anche cercato un'alternativa che sia più semplice. Spero che qualcun altro condivida una soluzione migliore per questo problema. – MichaelP
Ma questa soluzione nasconde i pulsanti quando viene visualizzata la tastiera virtuale. Ma a seconda della risoluzione dello schermo, ecc., Potrebbe non essere necessario nascondere il pulsante, giusto? – Ted