Android 相关功能库
本文记录的是一些在android开发过程中需要用到的功能库路径以及用法。
一、网上图片加载库(glide)。
GitHub地址:https://github.com/bumptech/glide
anddroid引用:
compile 'com.github.bumptech.glide:glide:3.7.0'
代码库的实现调用:
Glide.with(mContext).load("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1561027386341&di=9104a579fc43965bd18dc0e8c6d54586&imgtype=0&src=http%3A%2F%2Fpic31.nipic.com%2F20130728%2F3822951_140613063000_2.jpg")
.into(holder.imageView);
二、模糊图片处理库(glide-transformations)
Github地址:https://github.com/wasabeef/glide-transformations
android引用:
compile 'jp.wasabeef:glide-transformations:3.0.1'
代码库的实现调用:
Glide.with(this).load("http://res.lgdsunday.club/poster-1.png")
.apply(RequestOptions.bitmapTransform(new BlurTransformation(25,10)))
.into(play_bg);
三、圆形图片处理库(CircleImageView)
GitHub地址:https://github.com/hdodenhof/CircleImageView
android引用:
compile 'de.hdodenhof:circleimageview:3.0.0'
代码库的实现调用:
<!--CircleImageView-->
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/music_bg"
android:layout_width="210dp"
android:layout_height="210dp"
android:layout_gravity="center"
app:civ_border_width="2dp"
app:civ_border_color="@color/titleColor"/>
四、android的工具类
这个工具类可以供各位学习,特别是里面各个功能的实现方法,没事的时候可以属性下。地址:https://blankj.com/2016/07/31/android-utils-code/
android的引用,当然后面的版本需要你自己根据你的SDK版本来确定,我用这个的时候
compileSdkVersion 26
minSdkVersion 17
targetSdkVersion 28,然后版本如下:
compile 'com.blankj:utilcode:1.11.1'
而官方文档中是是这样的:
implementation 'com.blankj:utilcode:1.25.2'
// if u use AndroidX, use the following
implementation 'com.blankj:utilcodex:1.25.2'
然后在Application中初始化加载这个工具类。
public class MyApplication extends Application {
public static Context context;
@Override
public void onCreate() {
super.onCreate();
Utils.init(this); //此处就是工具类的初始化
Realm.init(this);
RealmHelp.migration();
OkHttpUtil.init();
context = this;
}
public static Context getContext() {
return context;
}
}
工具类方法调用:
EncryptUtils.encryptMD5ToString(password); //MD5加密
五、ProgressBar进度条框架
先来看看效果图
上面效果图中自定义了各式各样的进度条和加载条,需要的同学可以自己去获取。
GitHub地址:https://github.com/bingoogolapple/BGAProgressBar-Android
implementation 'cn.bingoogolapple:bga-progressbar:1.0.1@aar'
六、Android 加载GIF图
GitHub地址:https://github.com/koral–/android-gif-drawable
星数:7.4K
添加依赖:
dependencies {
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'
}
布局引用:
<pl.droidsonroids.gif.GifImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/yiba_location "/>
属性设置:
GifImageView gifImageView = (GifImageView) findViewById(R.id.gifImageView);
GifDrawable gifDrawable = (GifDrawable) gifImageView.getDrawable();
gifDrawable.start(); //开始播放
gifDrawable.stop(); //停止播放
gifDrawable.reset(); //复位,重新开始播放
gifDrawable.isRunning(); //是否正在播放
gifDrawable.setLoopCount( 2 ); //设置播放的次数,播放完了就自动停止
gifDrawable.getCurrentLoop(); //获取正在播放的次数
gifDrawable.getCurrentPosition ; //获取现在到从开始播放所经历的时间
gifDrawable.getDuration() ; //获取播放一次所需要的时间
七、图片的放大缩小
GitHub地址:https://github.com/chrisbanes/PhotoView
星数:16.1K
依赖引用:
//图片放大缩小
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
布局引用:
<com.github.chrisbanes.photoview.PhotoView
android:layout_below="@id/load_image"
android:id="@+id/photo_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
具体调用:
/**
* 放大图片
*/
private void initBigImage() {
PhotoView photoView = (PhotoView) view.findViewById(R.id.photo_view);
//加载本地图片
photoView.setImageResource(R.drawable.image2);
//加载网上图片
Glide.with(view.getContext()).load("https://raw.githubusercontent.com/Thanks-xie/ImageWarehouse/master/images/image3.jpg").into(photoView);
}
后续用到的功能库,我会不定时的更新。未完待续。。。