一个加载动画界面LoadingViewR

本文介绍了如何在Android项目中集成并使用LoadingView-R库,通过Gradle或Maven添加依赖,并展示了在布局文件和代码中引用的步骤。提供了一种简单的方法来创建和控制加载动画,为应用添加视觉吸引力。
摘要由CSDN通过智能技术生成

前言

github地址

预览效果

使用

一、添加依赖

有两种方法:GradleMaven

1.Gradle

在项目的gradle.build

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

添加依赖

dependencies {
	        implementation 'com.github.Yuki-r:LoadingView-R:1.0.1'
	}

2.使用Maven

<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>
<dependency>
	    <groupId>com.github.Yuki-r</groupId>
	    <artifactId>LoadingView-R</artifactId>
	    <version>1.0.1</version>
	</dependency>

二、在布局文件中引用

 <com.loadingview_r.loadingviewr.LoadingViewR
        android:id="@+id/loadingView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView"
        <!--界面设置,不设置则使用默认值-->
        app:lineNumber="3"       //设置方块行数
        app:fixBlock_Angle="5"   //设置固定方块的角度
        app:moveBlock_Angle="20" //设置移动方块的角度

        app:blockInterval="8dp"  //方块间隔
        app:half_BlockWidth="15dp" //方块大小
        app:initPosition="0"  //移动方块的初始位置

        app:isClock_Wise="false" //ture顺时针旋转,false逆时针旋转
        app:moveSpeed="500" //移动速度
        />

三、在代码中引用

private LoadingViewR loadingViewR;
...
loadingViewR = findViewById(R.id.LoadingView_r);
 loadingViewR.startMoving(); //启动
 loadingViewR.stopMoving(); //停止

结语

如果此文对你有帮助,欢迎收藏点赞!


参考自:

你也可以自己写一个可爱 & 小资风格的Android加载等待自定义View

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值