我想像 exapnd 和 collapse 那样动态更改视图高度,并且按钮的位置(y)也应该改变..它就像移动按钮并根据那个扩展视图..
我的代码是......
button.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_MOVE) {
int height = (int) event.getY();
android.widget.RelativeLayout.LayoutParams lpview =
(android.widget.RelativeLayout.LayoutParams) view
.getLayoutParams();
android.widget.RelativeLayout.LayoutParams lpbutton =
(android.widget.RelativeLayout.LayoutParams) button
.getLayoutParams();
lpbutton.topMargin = height;
button.setLayoutParams(lpbutton);
lpview.height = height;
view.setLayoutParams(lpview);
}
return true;
}
});
但我的问题是在扩展时它不能顺利扩展......有什么建议吗????