progress-activity
介绍:
如果你厌倦了反反复复设置progress bar,空视图,错误视图,那么这个库就是为你准备的。progress-activity其实并不是activity,而是一个RelativeLayout。
运行效果:
使用说明:
添加 com.vlonjatg.progressactivity.ProgressActivity 到布局。
<com.vlonjatg.progressactivity.ProgressActivity
android:id="@+id/progressActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/activityToolbar"
progressActivity:loadingStateBackgroundColor="#FFFFFF"
progressActivity:progressEmptyStateBackgroundColor="#fbc02d"
progressActivity:progressErrorStateBackgroundColor="#42a5f5">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:text="@string/hello_world" />
</com.vlonjatg.progressactivity.ProgressActivity>
然后在代码中:
显示loading view:
progressActivity.showLoading();
显示empty view:
progressActivity.showEmpty(emptyDrawable, "Empty Shopping Cart",
"Please add things in the cart to continue.");
显示error view:
progressActivity.showError(errorDrawable, "No Connection",
"We could not establish a connection with our servers. Try again when you are connected to the interne.",
"Try Again", errorClickListener);
获取
allprojects {
repositories {
jcenter()
}
}
dependencies {
compile 'com.vlonjatg.android:progress-activity:1.1.1'
}
自定义
有一些列自定义这些view的属性:
<attr name="progressLoadingStateProgressBarWidth" format="dimension"/>
<attr name="progressLoadingStateProgressBarHeight" format="dimension"/>
<attr name="progressLoadingStateBackgroundColor" format="color"/>
<attr name="progressEmptyStateImageWidth" format="dimension"/>
<attr name="progressEmptyStateImageHeight" format="dimension"/>
<attr name="progressEmptyStateTitleTextSize" format="dimension"/>
<attr name="progressEmptyStateContentTextSize" format="dimension"/>
<attr name="progressEmptyStateTitleTextColor" format="color"/>
<attr name="progressEmptyStateContentTextColor" format="color"/>
<attr name="progressEmptyStateBackgroundColor" format="color"/>
<attr name="progressErrorStateImageWidth" format="dimension"/>
<attr name="progressErrorStateImageHeight" format="dimension"/>
<attr name="progressErrorStateTitleTextSize" format="dimension"/>
<attr name="progressErrorStateContentTextSize" format="dimension"/>
<attr name="progressErrorStateTitleTextColor" format="color"/>
<attr name="progressErrorStateContentTextColor" format="color"/>
<attr name="progressErrorStateButtonTextColor" format="color"/>
<attr name="progressErrorStateBackgroundColor" format="color"/>
这个库的灵感来自于AndroidProgressLayout 。
ps:作者取名 progress-activity真的有点脑残。
已下载
0