android - 如何在 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);
解决方案
推荐阅读
- python - Python - 用另一个文件中的短代码动态替换长字段
- java - Java反转句子但不反转标点符号
- javascript - Mongoose 通过 ObjectID 从嵌套数组中拉出一个元素
- cakephp - 在 CakePHP 中,$_SESSION['Auth'] 和 Authentication->getIdentity() 有什么区别?
- python - Tornado-eventsource 服务器没有收到消息
- typescript - 满足条件时使用三元运算符更改图像 url
- python - django 渲染函数如何知道这个文件的位置?
- javascript - .then 之后 Javascript 未执行
- node.js - 如何获取使用 Inquirer 做出的选择的索引值?
- java - Jetpack 导航:如何从 recyclerview 适配器打开新片段?