{"id":287,"date":"2020-03-25T11:05:35","date_gmt":"2020-03-25T03:05:35","guid":{"rendered":"https:\/\/badgameshow.com\/fly\/?p=287"},"modified":"2021-01-20T10:32:28","modified_gmt":"2021-01-20T02:32:28","slug":"android-drawable-animation%e5%b9%80%e5%8b%95%e7%95%ab%e6%95%99%e5%ad%b8","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/fly\/android-drawable-animation%e5%b9%80%e5%8b%95%e7%95%ab%e6%95%99%e5%ad%b8\/","title":{"rendered":"Android Drawable Animation(\u5e40\u52d5\u756b)\u6559\u5b78"},"content":{"rendered":"<h3>1.\u5148\u5099\u59a5\u5716\u7247<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/yiYQ85g.png\" style=\"width: 15%; max-width: 210px;\"><br \/>\n<img decoding=\"async\" src=\"https:\/\/i.imgur.com\/o7ak8mb.png\" style=\"width: 15%; max-width: 210px;\"><br \/>\n<img decoding=\"async\" src=\"https:\/\/i.imgur.com\/FAbTlq0.png\" style=\"width: 15%; max-width: 210px;\"><br \/>\n<img decoding=\"async\" src=\"https:\/\/i.imgur.com\/Zdwl6t0.png\" style=\"width: 15%; max-width: 210px;\"><\/p>\n<h3>2.\u5728drawable\u4e0b\u5efa\u7acb\u4e00\u500bxml\u6a94(loading.xml)<\/h3>\n<pre><code class=\"language-XML line-numbers\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n&lt;animation-list xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\" android:oneshot=\"false\"&gt;\n    &lt;item android:drawable=\"@drawable\/loading_1\" android:duration=\"200\"\/&gt;\n    &lt;item android:drawable=\"@drawable\/loading_2\" android:duration=\"200\"\/&gt;\n    &lt;item android:drawable=\"@drawable\/loading_3\" android:duration=\"200\"\/&gt;\n    &lt;item android:drawable=\"@drawable\/loading_4\" android:duration=\"200\"\/&gt;\n&lt;\/animation-list&gt;\n<\/code><\/pre>\n<h3>3.\u81ea\u5b9a\u7fa9\u8981\u986f\u793a\u7684\u756b\u9762(loading_layout.xml)<\/h3>\n<pre><code class=\"language-XML line-numbers\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n&lt;androidx.constraintlayout.widget.ConstraintLayout\n    xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\n    xmlns:app=\"http:\/\/schemas.android.com\/apk\/res-auto\"\n    xmlns:tools=\"http:\/\/schemas.android.com\/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"&gt;\n\n    &lt;ImageView\n        android:id=\"@+id\/loading_img\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        app:layout_constraintBottom_toBottomOf=\"parent\"\n        app:layout_constraintEnd_toEndOf=\"parent\"\n        app:layout_constraintStart_toStartOf=\"parent\"\n        app:layout_constraintTop_toTopOf=\"parent\"\n        tools:srcCompat=\"@tools:sample\/avatars\" \/&gt;\n&lt;\/androidx.constraintlayout.widget.ConstraintLayout&gt;\n<\/code><\/pre>\n<h3>4.\u81ea\u5b9a\u7fa9\u7684\u756b\u9762\u6dfb\u52a0\u5230AlertDialog<\/h3>\n<pre><code class=\"language-Kotlin line-numbers\">val view = LayoutInflater.from(this).inflate(R.layout.loading_layout,null)\nval loadingImg: ImageView = view.findViewById(R.id.loading_img)\nloadingImg.setBackgroundResource(R.drawable.loading)\n\nval animationDrawable = loadingImg.background as AnimationDrawable\nanimationDrawable.start()\nval alert = AlertDialog.Builder(this)\n    .setView(view)\n    .create()\n\nval window = alert.window\nwindow?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))\nalert.show()\n<\/code><\/pre>\n<h3>5.\u5b8c\u6210\u52d5\u756b<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/YFlrObH.gif\" style=\"width: 50%; max-width: 210px;\"><\/p>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>1.\u5148\u5099\u59a5\u5716\u7247 2.\u5728drawable\u4e0b\u5efa\u7acb\u4e00\u500bxml\u6a94(loading.xml) &lt;?xml vers &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"pgc_sgb_lightbox_settings":"","footnotes":""},"categories":[5],"tags":[13,29,15],"class_list":["post-287","post","type-post","status-publish","format-standard","hentry","category-android","tag-android","tag-animation","tag-kotlin"],"_links":{"self":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/287","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/comments?post=287"}],"version-history":[{"count":6,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/287\/revisions"}],"predecessor-version":[{"id":1089,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/287\/revisions\/1089"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/media?parent=287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/categories?post=287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/tags?post=287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}