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

Android自定義加載圈的方法

 更新時間:2022年06月22日 08:27:23   作者:這個殺手不太累  
這篇文章主要為大家詳細(xì)介紹了Android自定義加載圈的方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android自定義加載圈的具體代碼,供大家參考,具體內(nèi)容如下

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
? ? xmlns:app="http://schemas.android.com/apk/res-auto"
? ? xmlns:tools="http://schemas.android.com/tools"
? ? android:layout_width="match_parent"
? ? android:layout_height="match_parent"
? ? tools:context="com.tlkg.welcome.loadingviewdemo.MainActivity">

? ? <com.tlkg.welcome.loadingviewdemo.LoadingView
? ? ? ? android:layout_width="150dp"
? ? ? ? android:layout_height="150dp"
? ? ? ? android:layout_centerInParent="true" />

</RelativeLayout>
public class LoadingView extends LinearLayout {
? ? public LoadingView(Context context) {
? ? ? ? this(context, null);
? ? }

? ? public LoadingView(Context context, @Nullable AttributeSet attrs) {
? ? ? ? this(context, attrs, 0);
? ? }

? ? public LoadingView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
? ? ? ? super(context, attrs, defStyleAttr);

? ? ? ? setOrientation(VERTICAL);
? ? ? ? setGravity(Gravity.CENTER);
? ? ? ? setBackgroundResource(R.drawable.loadingsp);

? ? ? ? LoadView loading = new LoadView(getContext());
? ? ? ? loading.setLayoutParams(new ViewGroup.LayoutParams(200, 200));
? ? ? ? addView(loading);

? ? ? ? TextView tv = new TextView(getContext());
? ? ? ? tv.setText("正在加載中");
? ? ? ? LinearLayout.LayoutParams layoutParams = new LayoutParams(-2, -2);
? ? ? ? layoutParams.setMargins(0, 10, 0, 0);
? ? ? ? tv.setLayoutParams(layoutParams);
? ? ? ? tv.setGravity(Gravity.CENTER);
? ? ? ? tv.setTextColor(Color.WHITE);
? ? ? ? addView(tv);
? ? }


? ? class LoadView extends View {

? ? ? ? Paint mPaint;

? ? ? ? private int mWidth;
? ? ? ? private int mHeight;

? ? ? ? private int mCurrentIndex = 0;

? ? ? ? private int count = 12;

? ? ? ? public LoadView(Context context) {
? ? ? ? ? ? super(context);
? ? ? ? ? ? mPaint = new Paint();
? ? ? ? ? ? mPaint.setAntiAlias(true);
? ? ? ? ? ? mPaint.setStyle(Paint.Style.FILL);
? ? ? ? ? ? mPaint.setStrokeWidth(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3, getResources().getDisplayMetrics()));
? ? ? ? ? ? mPaint.setColor(Color.WHITE);
? ? ? ? }

? ? ? ? @Override
? ? ? ? protected void onDraw(Canvas canvas) {
? ? ? ? ? ? super.onDraw(canvas);
? ? ? ? ? ? if (mCurrentIndex >= count) {
? ? ? ? ? ? ? ? mCurrentIndex = 0;
? ? ? ? ? ? }

? ? ? ? ? ? int endAlpha = 255 / count;
? ? ? ? ? ? for (int i = 0; i < count; i++) {
? ? ? ? ? ? ? ? int alpha;
? ? ? ? ? ? ? ? if (mCurrentIndex - i > 0) {
? ? ? ? ? ? ? ? ? ? alpha = endAlpha * (mCurrentIndex - i);
? ? ? ? ? ? ? ? } else {
? ? ? ? ? ? ? ? ? ? alpha = 255 - 255 / count * (i - mCurrentIndex);
? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? mPaint.setColor(Color.argb(alpha, 255, 255, 255));
? ? ? ? ? ? ? ? canvas.drawLine(mWidth / 2, 0, mWidth / 2, TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, getResources().getDisplayMetrics()), mPaint);
? ? ? ? ? ? ? ? canvas.rotate(360 / count, mWidth / 2, mHeight / 2);
? ? ? ? ? ? }
? ? ? ? ? ? mCurrentIndex++;
? ? ? ? ? ? postInvalidateDelayed(100);
? ? ? ? }

? ? ? ? @Override
? ? ? ? protected void onSizeChanged(int w, int h, int oldw, int oldh) {
? ? ? ? ? ? super.onSizeChanged(w, h, oldw, oldh);
? ? ? ? ? ? mWidth = getWidth();
? ? ? ? ? ? mHeight = getHeight();
? ? ? ? }
? ? }
}
<shape xmlns:android="http://schemas.android.com/apk/res/android">
? ? <corners android:radius="5dp" />
? ? <solid android:color="#aa000000" />
</shape>

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

相關(guān)文章

  • Android studio 生成帶Kotlin文檔的實(shí)現(xiàn)方式

    Android studio 生成帶Kotlin文檔的實(shí)現(xiàn)方式

    這篇文章主要介紹了Android studio 生成帶Kotlin文檔的實(shí)現(xiàn)方式,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-03-03
  • android 使用uinput模擬輸入設(shè)備的方法

    android 使用uinput模擬輸入設(shè)備的方法

    這篇文章主要介紹了android 使用uinput模擬輸入設(shè)備的方法,有需要的朋友可以參考一下
    2014-01-01
  • Android中的Bitmap的詳細(xì)介紹

    Android中的Bitmap的詳細(xì)介紹

    本篇文章主要介紹了Android中的Bitmap,是Windows標(biāo)準(zhǔn)格式圖形文件,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-01-01
  • 一文詳解在Android中Service和AIDL的使用

    一文詳解在Android中Service和AIDL的使用

    Service是Android四大組件之一,它是不依賴于用戶界面的,就是因?yàn)镾ervice不依賴與用戶界面,本文將詳細(xì)介紹在Android中Service和AIDL的使用,感興趣的同學(xué)可以參考本文
    2023-04-04
  • Kotlin匿名函數(shù)使用介紹

    Kotlin匿名函數(shù)使用介紹

    定義時不取名字的函數(shù),我們稱之為匿名函數(shù),匿名函數(shù)通常整體傳遞給其他函數(shù)或者從其他函數(shù)返回,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-08-08
  • Android 實(shí)現(xiàn)秒轉(zhuǎn)換成時分秒的方法

    Android 實(shí)現(xiàn)秒轉(zhuǎn)換成時分秒的方法

    這篇文章主要介紹了Android 實(shí)現(xiàn)秒轉(zhuǎn)換成時分秒的方法,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-05-05
  • Android邊框裁切的正確姿勢實(shí)現(xiàn)示例

    Android邊框裁切的正確姿勢實(shí)現(xiàn)示例

    這篇文章主要為大家介紹了Android邊框裁切的正確姿勢實(shí)現(xiàn)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-02-02
  • Android P實(shí)現(xiàn)靜默安裝的方法示例(官方Demo)

    Android P實(shí)現(xiàn)靜默安裝的方法示例(官方Demo)

    這篇文章主要介紹了Android P實(shí)現(xiàn)靜默安裝,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-02-02
  • Android開發(fā)之彈出軟鍵盤工具類簡單示例

    Android開發(fā)之彈出軟鍵盤工具類簡單示例

    這篇文章主要介紹了Android開發(fā)之彈出軟鍵盤工具類,結(jié)合實(shí)例形式分析了Android彈出軟鍵盤及獲取焦點(diǎn)的簡單操作技巧,需要的朋友可以參考下
    2018-01-01
  • Android實(shí)現(xiàn)郵箱驗(yàn)證功能

    Android實(shí)現(xiàn)郵箱驗(yàn)證功能

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)郵箱驗(yàn)證功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-05-05

最新評論

昔阳县| 杭州市| 兴文县| 凉城县| 嘉峪关市| 福泉市| 涿州市| 永寿县| 榆树市| 晋城| 海安县| 汉中市| 盘山县| 晋城| 龙口市| 格尔木市| 若尔盖县| 福鼎市| 宜川县| 巩留县| 垣曲县| 樟树市| 乳山市| 新竹市| 柏乡县| 昔阳县| 仙游县| 资兴市| 出国| 双鸭山市| 济宁市| 特克斯县| 宜州市| 嘉兴市| 辉县市| 泸州市| 闻喜县| 五大连池市| 武定县| 亚东县| 太原市|