您好
我的问题是我想调整我的片段大小我向上/向下滑动片段然后我成功了但是问题是片段上的内容不会调整大小所以我的问题是如何调整大小片段内的内容还是可能吗?
我的代码看起来像这样
private View.OnTouchListener onTouchListener = new View.OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
int minWidth = (int)((double)main_container.getWidth() * .33);
int maxHeight = main_container.getHeight();
float container_ratio = (float)main_container.getHeight() / (float)main_container.getWidth();
int height = (int)event.getY();
int width = (int)(event.getY() / container_ratio);
if (width < minWidth || height > maxHeight) {
return true;
}
if (prevTouchEvent == MotionEvent.ACTION_MOVE && oldY != event.getY() && oldY != -1) {
RelativeLayout.LayoutParams layout = (RelativeLayout.LayoutParams)fragment_broadcast.getLayoutParams();
// layout.setMargins(0, 0, (int)ScreenUtils.dipToPixel(MainActivity.this, 10), 0);
layout.height = height;
layout.width = width;
fragment_broadcast.setLayoutParams(layout);
}
}
}