2
onClick을 호출 할 때 버튼에 애니메이션을 만드는 방법에 대한 답을 찾지 못했습니다. 나는 custom_btn.xml과 같이있어 :Android에서 OnClick의 버튼 애니메이션을 표시 하시겠습니까?
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/btn_pressed"></item>
<item android:state_focused="true" android:drawable="@drawable/btn_on"></item>
<item android:drawable="@drawable/btn"></item>
</selector>
및 애니메이션과 같이 btn_pressed.xml에 있습니다
내 문제는 내가 올바른 코드를 찾을 수 없습니다 것입니다<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/btn_on_1" android:duration="30" />
<item android:drawable="@drawable/btn_on_2" android:duration="30" />
<item android:drawable="@drawable/btn_on_3" android:duration="30" />
<item android:drawable="@drawable/btn_on_4" android:duration="30" />
<item android:drawable="@drawable/btn_on_5" android:duration="30" />
</animation-list>
여기에 onClickListener에 들어가기 :
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//-- what is the proper animation call that would go here
to make btn_pressed.xml cycle only once when pressed?
}
});
감사합니다! 안드로이드 문서에서
감사합니다. 당신이 준 링크가 도움이되었습니다. 내가해야 할 일은 모두 android : oneshot = "true"를 btn_pressed.xml에 추가하는 것입니다. – kirktoon1882