這是一個簡單的方法使用視圖動畫類來做到這一點:
final ImageView aboutButton = (ImageView) findViewById(R.id.AboutButton);
aboutButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Animation myAnim2 = AnimationUtils.loadAnimation(LaunchActivity.this, R.anim.buttons);
aboutButton.startAnimation(myAnim2);
myAnim2.setAnimationListener(new AnimationListener() {
public void onAnimationEnd(Animation animation) {
//do on click after animation ends
Intent intent = new Intent(LaunchActivity.this, MyDialog.class);
startActivity(intent);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationStart(Animation animation) {
//change the backround of the button etc on click etc...
}
});
}});
不適合ImageView的好,因爲我不能改變的背景什麼的。但是,感謝這個想法。 –
再次仔細閱讀您的問題後,我認爲最簡單的方法是將它繪製在您的自定義視圖中,因爲它已經爲它設置了一切。否則,您可以在RelativeLayout中使用其左側和頂部邊距在自定義頂部添加圖像視圖,但必須觀察不同的屏幕尺寸...... – Lumis
我認爲您是對的,這是最簡單的方法。我擴展了我的onDraw方法,在原始圖像上的同一個畫布上繪製圖像。 –