TV-side: Through the remote control to achieve the image of the upper and lower left and right jitter effect

Source: Internet
Author: User

Do TV side for a while, I saw another TV on a touch pad through the remote control of a picture of the corresponding direction of the jitter, feel the novelty of listening to, try to do a share:

Reprint Annotated Source: http://www.cnblogs.com/hyylog/p/5666806.html

In fact, it is very simple to control by rotating animation:

Directly on the code:

public class Imagesew extends ImageView {
private int state = 0;//0 Normal 1 Tilt 2 under Tilt 3 do tilt 4 right tilt
private int degress;
Private Valueanimator Startanimator;
Private Valueanimator Endanimator;

Public Imagesew (context context, AttributeSet Attrs) {
Super (context, attrs);
}

@Override
protected void OnDraw (canvas canvas) {
Super.ondraw (canvas);
}
public void initeanimation (int member, int duration) {
degress = member;
Startanimator = Valueanimator.ofint (0,member);
Endanimator = Valueanimator.ofint (0,member);
Startanimator.setduration (duration);
Endanimator.setduration (duration);
Startanimator.addlistener (New Animatorlistener () {

@Override
public void Onanimationstart (Animator animation) {

}

@Override
public void Onanimationrepeat (Animator animation) {

}

@Override
public void Onanimationend (Animator animation) {
Endanimator.start ();
Endanimator.addlistener (New Animatorlistener () {

@Override
public void Onanimationstart (Animator animation) {

}

@Override
public void Onanimationrepeat (Animator animation) {

}

@Override
public void Onanimationend (Animator animation) {
Setrotationx (0);
Setrotationx (0);
}

@Override
public void Onanimationcancel (Animator animation) {

}
});
}

@Override
public void Onanimationcancel (Animator animation) {

}
});

Startanimator.addupdatelistener (New Animatorupdatelistener () {

@Override
public void Onanimationupdate (Valueanimator animation) {
int value = (Integer) animation.getanimatedvalue ();
if (state==1)
Setrotationx (value);
else if (state==2)
Setrotationx (0-value);
else if (state = = 3)
Setrotationy (0-value);
else if (state = = 4)
Setrotationy (value);
}
});

Endanimator.addupdatelistener (New Animatorupdatelistener () {

@Override
public void Onanimationupdate (Valueanimator animation) {
int value = (Integer) animation.getanimatedvalue ();
if (state==1)
Setrotationx (Degress-value);
else if (state==2)
Setrotationx (value-degress);
else if (state = = 3)
Setrotationy (value-degress);
else if (state = = 4)
Setrotationy (Degress-value);
}
});
}

@Override
protected void Dispatchdraw (canvas canvas) {
Super.dispatchdraw (canvas);
}

public void Upbitmap () {
state = 1;
Start ();
}

public void Downbitmap () {
state = 2;
Start ();
}

public void Leftbitmap () {
state = 3;
Start ();
}

public void Rightbitmap () {
state = 4;
Start ();
}

public void Start () {
Cancelanimation ();
Startanimator.start ();
}

public void Cancelanimation () {
Startanimator.cancel ();
Endanimator.cancel ();
Setrotationx (0);
Setrotationy (0);
}

}

TV-side: Through the remote control to achieve the image of the upper and lower left and right jitter effect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.