首页 > 解决方案 > 如何在 android 的约束布局参数中访问下面的图像

问题描述

我对容器使用约束布局。我必须将相机和画廊中的图像添加到容器中,所以我必须使用布局参数。当我添加imageview并将其设置为容器时,我无法访问imageview。我必须做事件移动、旋转、缩放。我必须使用触摸监听器访问 imageview。请帮我。谢谢。

layoutParams = (ConstraintLayout.LayoutParams) ivCarpet.getLayoutParams();
        layoutParams.width = Math.round(ViewUtil.dpToPx(workSpaceWidth));
        layoutParams.height = Math.round(ViewUtil.dpToPx(workSpaceHeight));
        carpetContent.removeView(ocv);
        ivCarpet.setLayoutParams(layoutParams);


 imageView.setLayoutParams(layoutParams);
        imageView.setMaxWidth((int) sizeImage[0] / 4);
        imageView.setMaxHeight((int) sizeImage[1] / 4);
        imageView.setScaleType(ImageView.ScaleType.MATRIX);
        carpetContent.addView(imageView);

标签: androidandroid-layoutandroid-constraintlayoutandroid-layoutparams

解决方案


推荐阅读