【发布时间】:2015-11-13 23:40:33
【问题描述】:
我有 2 张图片和一个可将图片拉近的按钮。现在我需要一个文本字段来显示两个图像之间的距离(以像素为单位)。所以标签可以显示图像彼此相距 20 像素,或者如果我将图像移近,文本字段将显示 19 像素。
这是我的代码
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((ViewGroup.MarginLayoutParams) red.getLayoutParams()).topMargin += 1;
red.requestLayout();
((ViewGroup.MarginLayoutParams) blue.getLayoutParams()).topMargin -= 1.5;
blue.requestLayout();
text2.setText("" + (int) red.getCameraDistance());
'text2.setText("" =...." 行代码,是我试图找出两张图像之间的距离的尝试。但它没有用......
【问题讨论】:
-
你有没有尝试过?尝试一下,看看你会得到什么。
标签: android image button textfield pixels