android设置布局滑动,设置android时如何滚动我的布局:windowSoftInputMode =“adjustPan”?...

最后,我找到了我的问题的解决方法,所以我想分享给某人可能会在将来遇到同样的问题.我的布局简要描述如下:

//all stuff controls:editview,textview,....

我创建自定义类myRelativeLayout扩展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;

}

}

在我的活动中,我只是为myRelativeLayout设置setLayoutChangeListener以在软键盘显示时隐藏底栏并在软键盘隐藏时显示底栏:

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.

}

});

不要忘记为活动设置android:windowSoftInputMode =“adjustResize”.希望这对有人遇到同样问题很有用.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值