Android自定義加載控件實(shí)現(xiàn)數(shù)據(jù)加載動(dòng)畫(huà)
本文實(shí)例為大家分享了Android自定義加載控件,第一次小人跑動(dòng)的加載效果眼前一亮,相比傳統(tǒng)的PrograssBar高大上不止一點(diǎn),于是走起,自定義了控件LoadingView去實(shí)現(xiàn)動(dòng)態(tài)效果,可直接在xml中使用,具體實(shí)現(xiàn)如下
package com.*****.*****.widget; import android.content.Context; import android.graphics.drawable.AnimationDrawable; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; /** * Created by Xiaomu * 數(shù)據(jù)加載控件 */ public class LoadingView extends RelativeLayout { private Context mContext; private ImageView loadingIv; private TextView loadingTv; public LoadingView(Context context) { super(context); this.mContext = context; initView(); } public LoadingView(Context context, AttributeSet attrs) { super(context, attrs); this.mContext = context; initView(); } private void initView() { View view = LayoutInflater.from(mContext).inflate(R.layout.loading, null); loadingIv = (ImageView) view.findViewById(R.id.loadingIv); loadingTv = (TextView) view.findViewById(R.id.loadingTv); AnimationDrawable animationDrawable = (AnimationDrawable) loadingIv.getBackground(); if (animationDrawable != null) animationDrawable.start(); addView(view); } public ImageView getLoadingIv() { return loadingIv; } public TextView getLoadingTv() { return loadingTv; } }
2. xml布局文件
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:id="@+id/loadingIv" android:layout_width="@dimen/dimen_144_dip" android:layout_height="@dimen/dimen_162_dip" android:layout_centerHorizontal="true" android:background="@anim/loading_anim" /> <TextView android:id="@+id/loadingTv" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignBottom="@+id/loadingIv" android:layout_centerHorizontal="true" android:gravity="center_horizontal" android:text="正在加載中..." android:textSize="15sp" /> </RelativeLayout>
3. loading_anim加載動(dòng)畫(huà)的xml
<?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"> <item android:drawable="@drawable/progress_loading_image_01" android:duration="150" /> <item android:drawable="@drawable/progress_loading_image_02" android:duration="150" /> </animation-list>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家學(xué)習(xí)使用Android自定義加載控件有所啟發(fā)。
- Android自定義Animation實(shí)現(xiàn)View搖擺效果
- Android Animation實(shí)戰(zhàn)之一個(gè)APP的ListView的動(dòng)畫(huà)效果
- Android使用glide加載gif動(dòng)畫(huà)設(shè)置播放次數(shù)
- Android Glide圖片加載(加載監(jiān)聽(tīng)、加載動(dòng)畫(huà))
- Android實(shí)現(xiàn)跳動(dòng)的小球加載動(dòng)畫(huà)效果
- Android自定義加載loading view動(dòng)畫(huà)組件
- Android加載Gif動(dòng)畫(huà)實(shí)現(xiàn)代碼
- Android自定義view實(shí)現(xiàn)阻尼效果的加載動(dòng)畫(huà)
- Android自定義View實(shí)現(xiàn)loading動(dòng)畫(huà)加載效果
- Android使用View Animation實(shí)現(xiàn)動(dòng)畫(huà)加載界面
相關(guān)文章
Android實(shí)現(xiàn)相冊(cè)中圖片上傳或下載
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)相冊(cè)中圖片上傳或下載,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-05-05Android利用CountDownTimer實(shí)現(xiàn)倒計(jì)時(shí)功能 Android實(shí)現(xiàn)停留5s跳轉(zhuǎn)到登錄頁(yè)面
這篇文章主要為大家詳細(xì)介紹了Android利用CountDownTimer實(shí)現(xiàn)倒計(jì)時(shí)功能,Android實(shí)現(xiàn)停留5s跳轉(zhuǎn)到登錄頁(yè)面,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07Android 實(shí)現(xiàn)帶字母索引的側(cè)邊欄功能
這篇文章主要介紹了Android 實(shí)現(xiàn)帶字母索引的側(cè)邊欄功能,需要的朋友可以參考下2017-08-08Android通過(guò)XListView實(shí)現(xiàn)上拉加載下拉刷新功能
這篇文章主要為大家詳細(xì)介紹了Android通過(guò)XListView實(shí)現(xiàn)上拉加載下拉刷新功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-12-12淺析Android手機(jī)衛(wèi)士之手機(jī)實(shí)現(xiàn)短信指令獲取位置
這篇文章主要介紹了淺析Android手機(jī)衛(wèi)士之手機(jī)實(shí)現(xiàn)短信指令獲取位置的相關(guān)資料,需要的朋友可以參考下2016-04-04Android學(xué)習(xí)之SharedPerference存儲(chǔ)詳解
這篇文章主要為大家詳細(xì)介紹了Android學(xué)習(xí)之SharedPerference存儲(chǔ)的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-08-08Android點(diǎn)擊Button實(shí)現(xiàn)功能的幾種方法總結(jié)
當(dāng)Button有多個(gè)或者Button的使用次數(shù)很多時(shí),我們需要采用綁定監(jiān)聽(tīng)器的做法,其實(shí),綁定監(jiān)聽(tīng)器也有幾種方法,不過(guò),我在這里就不一一列舉了,畢竟那些方法在實(shí)際的應(yīng)用中也不常見(jiàn)2013-10-10