【Android 基础】Progressbar 实现Loading动画

image.png

Progressbar 实现Loading动画

网络加载,播放视频 loading 时候界面会显示 转圈 等待提示动画,使用Android 自带的Progressbar 即可实现,在使用的时候控制其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>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    passiontim阅读 15,647评论 2 45
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 174,904评论 25 709
  • 蔡康永曾写过一段话:“15岁觉得游泳难,放弃游泳,到18岁遇到一个你喜欢的人约你去游泳,你只好说‘我不会耶’。18...
    果然说阅读 4,377评论 2 8
  • 小学本科毕业 字都不会写了 自己的名字都写的歪歪扭扭 还好有个神奇的手机 手机上有个简书 嘿嘿嘿 你们生活中...
    晓晨哥阅读 1,462评论 0 0
  • 英雄太遥远,今天只想聊聊小人物。 金庸与古龙的粉丝,每每在网上掐架。其实萝卜白菜各有所爱,谁好谁差只是一个见仁见智...
    风流人物志阅读 8,906评论 16 56