首页 > 代码库 > 帧动画
帧动画
main.
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView(); } private void initView() { ImageView mv=(ImageView) findViewById(R.id.imageView1); AnimationDrawable drawable = (AnimationDrawable) mv.getBackground(); drawable.start(); } }
2. main.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="myapplication.com.mydonghua.MainActivity"> <ImageView android:id="@+id/imageView1" android:layout_width="150dp" android:layout_height="150dp" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginLeft="122dp" android:layout_marginTop="183dp" android:background="@drawable/load" /> </RelativeLayout>
<!-------------------------->
drawable下的animation_list
<?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@mipmap/loading_0" android:duration="100"/> <item android:drawable="@mipmap/loading_1" android:duration="100"/> <item android:drawable="@mipmap/loading_2" android:duration="100"/> <item android:drawable="@mipmap/loading_3" android:duration="100"/> <item android:drawable="@mipmap/loading_4" android:duration="100"/> <item android:drawable="@mipmap/loading_5" android:duration="100"/> <item android:drawable="@mipmap/loading_6" android:duration="100"/> <item android:drawable="@mipmap/loading_7" android:duration="100"/> </animation-list>
帧动画
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。