【Android 基礎(chǔ)】Progressbar 實(shí)現(xiàn)Loading動(dòng)畫

image.png

Progressbar 實(shí)現(xiàn)Loading動(dòng)畫

網(wǎng)絡(luò)加載,播放視頻 loading 時(shí)候界面會(huì)顯示 轉(zhuǎn)圈 等待提示動(dòng)畫,使用Android 自帶的Progressbar 即可實(shí)現(xiàn),在使用的時(shí)候控制其Visible 屬性;

布局layout目錄文件中添加Progressbar

<ProgressBar
            android:id="@+id/help_center_loading_prgbar"
            style="@style/CustomProgressBar_Small"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:visibility="visible"/>

Value/style.xml中添加:

<style name="CustomProgressBar_Small">
        <item name="android:indeterminateDrawable">@drawable/progress_small_holo</item>
        <item name="android:minWidth">27dip</item>
        <item name="android:maxWidth">27dip</item>
        <item name="android:minHeight">27dip</item>
        <item name="android:maxHeight">27dip</item>
    </style>

drawable 目錄添加progress_small_holo.xml 文件

<?xml version="1.0" encoding="utf-8"?>
<!--
 Copyright 2010, The Android Open Source Project

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <rotate
             android:drawable="@drawable/loading_small"
             android:pivotX="50%"
             android:pivotY="50%"
             android:fromDegrees="0"
             android:toDegrees="720" />
    </item>
</layer-list>
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • afinalAfinal是一個(gè)android的ioc,orm框架 https://github.com/yangf...
    passiontim閱讀 15,898評(píng)論 2 45
  • Android 自定義View的各種姿勢(shì)1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 179,324評(píng)論 25 708
  • 蔡康永曾寫過一段話:“15歲覺得游泳難,放棄游泳,到18歲遇到一個(gè)你喜歡的人約你去游泳,你只好說‘我不會(huì)耶’。18...
    果然說閱讀 976評(píng)論 2 8
  • 小學(xué)本科畢業(yè) 字都不會(huì)寫了 自己的名字都寫的歪歪扭扭 還好有個(gè)神奇的手機(jī) 手機(jī)上有個(gè)簡書 嘿嘿嘿 你們生活中...
    曉晨哥閱讀 260評(píng)論 0 0
  • 英雄太遙遠(yuǎn),今天只想聊聊小人物。 金庸與古龍的粉絲,每每在網(wǎng)上掐架。其實(shí)蘿卜白菜各有所愛,誰好誰差只是一個(gè)見仁見智...
    風(fēng)流人物志閱讀 3,965評(píng)論 16 56

友情鏈接更多精彩內(nèi)容