0
我有一個imageview的並且需要知道在RelativeLayout的屏幕大小和位置,使彈出對話框右側在RelativeLayout的。如何在父傳位置的RelativeLayout
ImageView的是RelativeLayout的內部和監聽器是一個轉接器內,並需要傳遞的信息正確
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder vHolder;
if (convertView != null)
vHolder = (ViewHolder) convertView.getTag();
else {
convertView = mInflater.inflate(R.layout.car_list, null);
vHolder = new ViewHolder();
vHolder.textView = ((TextView) convertView.findViewById(R.id.tvCarListText));
vHolder.textView2 = ((TextView) convertView.findViewById(R.id.tvCarDescriptionListText));
vHolder.imageView = ((ImageView) convertView.findViewById(R.id.ivCarListMenuIcon));
vHolder.relativeLayout = ((RelativeLayout) convertView.findViewById(R.id.relativeLayout));
convertView.setTag(vHolder);
vHolder.imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Rect rect = new Rect();
v.getGlobalVisibleRect(rect);
showCarEditDialog(rect); //THIS NEED TO PASS RELATIVELAYOUT POSITION ON SCREEN<-------------
}
});
}
return convertView;
}
仍然需要一些幫助,我如何使它適合相對佈局 – rnascimento13
還有另一種方式獲取除view.getLocationOnScreen(screenLocation)之外的位置?????? – rnascimento13