【发布时间】:2015-10-15 06:45:24
【问题描述】:
我有一个 LinearLayout,其中包含几个子 ImageView(将 ImageViews 动态添加到 LinearLayout 水平)。长按子视图(ImageView)时,如何获取该 LinerLayout 的子视图的位置?
添加了 setTag:
image.setImageBitmap(resizedBitmap);
image.setTag(fullUrl);
imageViewLinearLayout.setOnLongClickListener(new View.OnLongClickListener(){
@Override
public boolean onLongClick(View v) {
Log.d("Mobi","Path :"+v.getTag());
return false;
}
});
添加设置标签为文件路径但返回v.getTag()为null"?
【问题讨论】:
-
试试
getLeft()/getX() -
好的“位置”是什么意思? (x,y) 在屏幕上的位置? (x,y) 在父布局中的位置?子视图数组中的索引?
标签: android