问题描述
我的活动有一个顶部栏和底部的酒吧。顶栏和底栏之间的空间我有几个内部意见的EditText一个LinearLayout中。因为我不希望我的布局调整每次softkeyboard显示时间,所以我设置的android:windowSoftInputMode =adjustPan我的清单中的活动。但是,当softkeyboard是openned,我要向下滚动,选择其他的EditText输入,它不允许我这样做。我只是能够在底部选择的EditText当我关闭softkeyboard。这是非常讨厌和不方便。
我怎样才能获得滚动型两种,并ajustpan模式softkeyboard工作得很好?
My activity have a top bar and a bottom bar. the space between topbar and bottom bar i have a linearlayout with several edittext views inside. Because i don't want my layout resize every time the softkeyboard show up, so i set android:windowSoftInputMode="adjustPan" for my activity in manifest. But when the softkeyboard is openned, i want to scroll down to select another edittext to input, it's not allow me do that. Im only able to select the edittext at bottom when i close the softkeyboard. That's very annoying and inconvenient.How can i get both scrollview and ajustpan mode for softkeyboard work well together?
请帮助我。感谢你这么多。
Please help me out. thanks you so much.
推荐答案
最后,我发现我的问题解决方法,所以我想分享的人可能得到未来同样的问题。我布局的简要描述如下:
At last, i find out a workaround for my problem, so i want to share for someone maybe get the same problem in future. A brief description of my layout as following:
<myRelativeLayout>
<topbar.../>
<myscrollView>
<linearLayout>
//all stuff controls:editview,textview,....
</linearLayout>
</myscrollView>
<bottombar.../>
我创建自定义的类myRelativeLayout扩展的RelativeLayout
i create custom class myRelativeLayout extend 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;
}
}
在我的活动,我只设置为setLayoutChangeListener myRelativeLayout隐藏bottombar时softkeyboard显示出来,并显示bottombar时softkeyboard隐藏:
And in my activity , i just set setLayoutChangeListener for myRelativeLayout to hide bottombar when softkeyboard show up and display bottombar when softkeyboard hide:
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.
}
});
对于活动windowSoftInputMode =adjustResize:
不要忘记设置机器人。
希望这个有用的人得到了同样的问题。
Dont forget set android:windowSoftInputMode="adjustResize" for activity.Hope this useful for someone got the same problem.
这篇关于如何设置机器人时滚动我的布局:windowSoftInputMode =&QUOT; adjustPan&QUOT;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!