Android 프레임 애니메이션 생 성 실례 상세 설명
선언:
우리 가 초기 영 화 를 볼 때 영 화 는 보통 한 장의 재생 이 었 다.우리 가 현재 가지 고 있 는 고유 명사 로 볼 때 바로 프레임 이 었 다.안 드 로 이 드 역시 이런 애니메이션 효과 의 편성 형식 을 가지 고 있다.
그러면 우 리 는 먼저 프레임 애니메이션 xml 파일 을 정의 합 니 다.
<?xml version="1.0" encoding="utf-8"?>
<animation-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item
android:drawable="@drawable/pic1"
android:duration="200" />
<item
android:drawable="@drawable/pic2"
android:duration="200" />
<item
android:drawable="@drawable/pic3"
android:duration="200" />
<item
android:drawable="@drawable/pic4"
android:duration="200" />
<item
android:drawable="@drawable/pic5"
android:duration="200" />
<item
android:drawable="@drawable/pic6"
android:duration="200" />
<item
android:drawable="@drawable/pic7"
android:duration="200" />
<item
android:drawable="@drawable/pic8"
android:duration="200" />
<item
android:drawable="@drawable/pic8"
android:duration="200" />
</animation-list>
main.xml
<ImageView
android:id="@+id/pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="98dp"
android:layout_marginTop="69dp"
/>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="54dp"
android:layout_marginLeft="98dp"
android:onClick="startMovie"
android:text=" " />
Activity 코드:
public class MyAnimationDemo extends Activity {
private AnimationDrawable draw=null;
private ImageView image;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_animation_demo);
image=(ImageView)super.findViewById(R.id.pic);
}
public void startMovie(View v){
image.setBackgroundResource(R.anim.oldvideo);// ,
draw=(AnimationDrawable)image.getBackground();// Drawable
draw.setOneShot(false);//
draw.start();//
}
}
여기 우리 가 봤 는데,첫 번 째,그림 배경 자원 설정
두 번 째 단 계 는 그림 배경 을 가 진 draw 를 설정 합 니 다.
세 번 째 단계,draw 인 자 를 설정 하고 start()
실현 효 과 는 다음 과 같다.0.2 초 간격 으로 그림 을 바 꾸 고 오래된 영화 애니메이션 효 과 를 실현 한다.
이상 은 바로 안 드 로 이 드 프레임 애니메이션 의 사례 상세 한 설명 입 니 다.궁금 한 점 이 있 으 시 면 메 시 지 를 남기 거나 본 사이트 지역사회 에 가서 토론 을 하 십시오.읽 어 주 셔 서 감사합니다. 여러분 께 도움 이 되 기 를 바 랍 니 다.본 사이트 에 대한 지지 에 감 사 드 립 니 다!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Bitrise에서 배포 어플리케이션 설정 테스트하기이 글은 Bitrise 광고 달력의 23일째 글입니다. 자체 또는 당사 등에서 Bitrise 구축 서비스를 사용합니다. 그나저나 며칠 전 Bitrise User Group Meetup #3에서 아래 슬라이드를 발표했...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.