我想动态地改变视图高度,如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;
}
});
但我的问题是在扩展时不能顺利扩展...任何建议????