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>