我想在 doubleTapEvent
上调整 ImageView
的大小。代码示例将非常有用。
最佳答案
XML:
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myImage"
android:src="@drawable/myPicture"
android:layout_width="64sp"
android:layout_height="64sp"
/>
Java:
public class MyActivity extends Activity implements OnDoubleTapListener{
private ImageView img;
private static int NEW_WIDTH = 100;
private static int NEW_HEIGHT = 100;
@Override
public void onCreate(Bundle savedInstanceState){
setContentView(R.layout.myLayout);
this.img = findViewById(R.id.myImage);
img.setOnDoubleTapListener(this);
}
public boolean onDoubleTap(MotionEvent e){
this.img.setLayoutParams(new LayoutParams(NEW_WIDTH, NEW_HEIGHT));
}
像这样的……
关于android - 在 onDoubleTapEvent 上调整 imageview 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4204373/