最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android實現(xiàn)加載圈

 更新時間:2022年06月21日 17:24:32   作者:阿毅同學(xué)  
這篇文章主要為大家詳細介紹了Android實現(xiàn)加載圈,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

開發(fā)過程中經(jīng)常用到加載圈,特別是車機開發(fā)由于外設(shè)不同很多操作響應(yīng)的等待時長經(jīng)常要用到不同的加載圈。

首先,直接上菊花效果圖,這是我直接從項目里面截取下來的。

核心代碼

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
?
?
public class CircularLoading {
/**
* 顯示Dialog
* @param context 上下文對象
* @param msg 提示內(nèi)容
* @param isCancelable 是否可以點擊取消
* @return
*/
public static Dialog showLoadDialog(Context context, String msg, boolean isCancelable) {
LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(R.layout.circular_loading, null);
RelativeLayout layout = (RelativeLayout) v.findViewById(R.id.dialog_bg);
?
// main.xml中的ImageView
ImageView loadImage = (ImageView) v.findViewById(R.id.load_iv);
TextView pointTextView = (TextView) v.findViewById(R.id.point_tv);
// 加載動畫
Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(context, R.anim.rotating_animation);
// 使用ImageView顯示動畫
loadImage.startAnimation(hyperspaceJumpAnimation);
pointTextView.setText(msg);
Dialog loadingDialog = new Dialog(context, R.style.TransDialogStyle);
loadingDialog.setContentView(layout);
loadingDialog.setCancelable(isCancelable);
loadingDialog.setCanceledOnTouchOutside(false);
?
?
Window window = loadingDialog.getWindow();
WindowManager.LayoutParams lp = window.getAttributes();
lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
window.setGravity(Gravity.CENTER);
window.setAttributes(lp);
window.setWindowAnimations(R.style.PopWindowAnimStyle);
loadingDialog.show();
return loadingDialog;
}
?
/**
* 關(guān)閉dialog
*/
public static void closeDialog(Dialog mCircularLoading) {
if (mCircularLoading != null && mCircularLoading.isShowing()) {
mCircularLoading.dismiss();
}
}
?
}

布局文件

circular_loading.xml 

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
? ? android:id="@+id/dialog_bg"
? ? android:layout_width="fill_parent"
? ? android:layout_height="fill_parent"
? ? android:background="#000000"
? ? android:minHeight="60dp"
? ? android:minWidth="150dp"
? ? android:orientation="horizontal" >
? ? <ImageView
? ? ? ? android:id="@+id/load_iv"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_alignParentLeft="true"
? ? ? ? android:layout_centerVertical="true"
? ? ? ? android:layout_marginLeft="20dp"
? ? ? ? android:layout_marginStart="20dp"
? ? ? ? android:src="@drawable/dialog_loading_img" />
? ? <TextView
? ? ? ? android:id="@+id/point_tv"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_centerVertical="true"
? ? ? ? android:layout_marginLeft="10dp"
? ? ? ? android:layout_marginTop="0dp"
? ? ? ? android:layout_toRightOf="@+id/load_iv"
? ? ? ? android:ellipsize="middle"
? ? ? ? android:singleLine="true"
? ? ? ? android:textSize="16sp" />
</RelativeLayout>

動畫

rotating_animation.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
? ? android:shareInterpolator="false">
? ? <rotate
? ? ? ? android:duration="1000"
? ? ? ? android:fromDegrees="0"
? ? ? ? android:interpolator="@android:anim/linear_interpolator"
? ? ? ? android:pivotX="50%"
? ? ? ? android:pivotY="50%"
? ? ? ? android:repeatCount="-1"
? ? ? ? android:repeatMode="restart"
? ? ? ? android:toDegrees="360" />

dialog_show.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
? ? <alpha android:fromAlpha="0"
? ? ? ? android:toAlpha="1.0"/>
?
</set>

dialog_hide.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="1.0"
? ? android:toAlpha="0"/>
</set>

Style

</style>
? ? ? ? <style name="TransDialogStyle" parent="@android:style/Theme.Dialog">
? ? ? ? <item name="android:windowFrame">@null</item>
? ? ? ? <item name="android:windowIsFloating">true</item>
? ? ? ? <item name="android:windowIsTranslucent">true</item>
? ? ? ? <item name="android:windowNoTitle">true</item>
? ? ? ? <item name="android:background">@android:color/transparent</item>
? ? ? ? <item name="android:windowBackground">@android:color/transparent</item>
? ? ? ? <item name="android:backgroundDimEnabled">true</item>
? ? ? ? <item name="android:backgroundDimAmount">0.5</item>
? ? ? ? <item name="android:windowFullscreen">true</item>
?
? ? </style>
?
? ? </style>
? ? ? ? <style name="PopWindowAnimStyle">
? ? ? ? <item name="android:windowShowAnimation">@anim/dialog_show</item>
? ? ? ? <item name="android:windowHideAnimation">@anim/dialog_hide</item>
</style>

使用方法

//顯示
mCircularLoading = CircularLoading.showLoadDialog(Dvr_Activity_Main.this, "加載中...", true);
?
//關(guān)閉
CircularLoading.closeDialog(mCircularLoading);

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Android自定義view實現(xiàn)多色進度條GradientProgressView的繪制

    Android自定義view實現(xiàn)多色進度條GradientProgressView的繪制

    我們常使用shape實現(xiàn)漸變色,但是shape的極限卻只有三色,如果有超過三種顏色的View的要求,那么我們就不得不去自定義View來實現(xiàn)這個需求,所以下面我們就來看看如何自定義view實現(xiàn)多色進度條的繪制吧
    2023-08-08
  • android照相、相冊獲取圖片剪裁報錯的解決方法

    android照相、相冊獲取圖片剪裁報錯的解決方法

    最近在項目中用到了照相和相冊取圖剪裁上傳頭像,就在網(wǎng)上逛了逛,基本都是千篇一律,就弄下來用了用,沒想到的是各種各樣的奇葩問題就出現(xiàn)了。先給大家看看代碼問題慢慢來解決
    2014-11-11
  • Android基于wheelView實現(xiàn)自定義日期選擇器

    Android基于wheelView實現(xiàn)自定義日期選擇器

    這篇文章主要為大家詳細介紹了Android基于wheelView實現(xiàn)自定義日期選擇器,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-07-07
  • android RecyclerView實現(xiàn)條目Item拖拽排序與滑動刪除

    android RecyclerView實現(xiàn)條目Item拖拽排序與滑動刪除

    本篇文章主要介紹了android RecyclerView實現(xiàn)條目Item拖拽排序與滑動刪除,具有一定的參考價值,感興趣的小伙伴們可以參考一下。
    2017-03-03
  • Android 實現(xiàn)桌面未讀角標

    Android 實現(xiàn)桌面未讀角標

    本文主要介紹了Android實現(xiàn)桌面未讀角標的相關(guān)知識。具有很好的參考價值。下面跟著小編一起來看下吧
    2017-04-04
  • Android Lottie實現(xiàn)中秋月餅變明月動畫特效實例

    Android Lottie實現(xiàn)中秋月餅變明月動畫特效實例

    Lottie是Airbnb開源的一個支持 Android、iOS 以及 ReactNative,利用json文件的方式快速實現(xiàn)動畫效果的庫,下面這篇文章主要給大家介紹了關(guān)于Android Lottie實現(xiàn)中秋月餅變明月動畫特效的相關(guān)資料,需要的朋友可以參考下
    2021-09-09
  • Android自定義View弧線進度控件

    Android自定義View弧線進度控件

    這篇文章主要為大家詳細介紹了Android自定義View弧線進度控件,點擊開始按鈕時,逐漸的出現(xiàn)進度,感興趣的小伙伴們可以參考一下
    2016-07-07
  • Android OpenGLES2.0繪制三角形(二)

    Android OpenGLES2.0繪制三角形(二)

    這篇文章主要為大家詳細介紹了Android OpenGLES2.0繪制三角形的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-12-12
  • Android使用Opengl錄像時添加水印

    Android使用Opengl錄像時添加水印

    這篇文章主要為大家詳細介紹了Android使用Opengl錄像時添加水印,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-04-04
  • Android簡單實用的可拖拽GridView組件分享

    Android簡單實用的可拖拽GridView組件分享

    在我們?nèi)粘i_發(fā)中,使用?GridView?這種網(wǎng)格視圖的場合還是不少的,本篇我們來介紹一個支持拖拽的?GridView?組件,可以輕松搞定網(wǎng)格視圖的拖拽排序,需要的可以參考一下
    2023-06-06

最新評論

中江县| 闽清县| 新龙县| 林西县| 江西省| 肇源县| 永丰县| 巴南区| 无极县| 鸡泽县| 图们市| 湖口县| 苏州市| 涿州市| 曲周县| 泸定县| 确山县| 张家港市| 陆丰市| 南漳县| 宜黄县| 福安市| 凌源市| 翁源县| 余姚市| 民乐县| 英德市| 肥西县| 望都县| 文登市| 黑河市| 海兴县| 平江县| 仲巴县| 宣恩县| 蒲城县| 福清市| 县级市| 丰原市| 澄迈县| 扎囊县|