开发者

Resize imageview on onDoubleTapEvent

开发者_如何学PythonI want to resize an ImageView on doubleTapEvent. A code example will be really helpful.


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));
    }

Something like this...


Above code is not working give error on img.setOnDoubleTapListener(this) line ... give such type of error "The method setOnDoubleTapListener(this) is the undefined for the type ImageView".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜