所以我像这样以编程方式创建我的视图:
for (int i = 0; i < num_devices; i++) {
ImageView imageView = new ImageView(this);
LinearLayout.LayoutParams vp = new LinearLayout.
LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
imageView.setLayoutParams(vp);
try {
Class res = R.drawable.class;
Field field = res.getField(device_types.get(i));
int resId = field.getInt(null);
imageView.setImageResource(resId);
}
catch (Exception e) {
Log.e("MyTag", "Failure to get drawable id.", e);
}
LinearLayout link_devices = (LinearLayout) findViewById(R.id.link_devices);
link_devices.addView(imageView);
}
我正在尝试获取图像视图的坐标:
我已经尝试了以下方法,但没有得到任何地方
imageView.getDrawable().getBounds().centerX() /centreY
imageView.getX() / getY
imageView.getLocationInWindow(); / onScreen();
有人可以向我解释如何获取可绘制图像的坐标,这样我就可以在它周围画一个框或在两个图像之间画线(这是计划的功能)