android 界面显示ProgressLayout
来源:互联网 发布:mysql示例数据库下载 编辑:程序博客网 时间:2024/06/05 09:09
项目地址:ProgressLayout
简介:An extension of RelativeLayout that helps show loading, empty and error layout.
An extension of RelativeLayout that helps show loading, empty and error layout.
Screenshot
Download
Add to your module's build.gradle:
allprojects { repositories { maven { url "https://jitpack.io" } }}
and:
dependencies { compile 'com.github.nguyenhoanglam:ProgressLayout:1.0.0'}
How to use
Use ProgressLayout like RelativeLayout in xml file.
<?xml version="1.0" encoding="utf-8"?><com.nguyenhoanglam.progresslayout.ProgressLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/progressLayout" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:layout_alignParentTop="true" android:background="@color/colorPrimary" app:theme="@style/CustomToolbarTheme" /> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@id/toolbar" android:layout_centerInParent="true" android:gravity="center" android:text="YOUR CONTENT HERE" android:textSize="24sp" /></com.nguyenhoanglam.progresslayout.ProgressLayout>
Call methods to show loading, empty or error when needed. ```java @Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle("Progress Layout"); ProgressLayout progressLayout = (ProgressLayout) findViewById(R.id.progressLayout); // Show progress layout and keep main views visible // skipIds is a list of view's ids which you want to show with ProgressLayout (in this case is the Toobar) List<Integer> skipIds = new ArrayList<>(); skipIds.add(R.id.toolbar); progressLayout.showLoading(skipIds); progressLayout.showEmpty(ContextCompat.getDrawable(this, R.drawable.ic_empty), "Empty data",skipIds); progressLayout.showError(ContextCompat.getDrawable(this, R.drawable.ic_no_connection), "No connection", "RETRY", new View.OnClickListener() { @Override public void onClick(View view) { Toast.makeText(MainActivity.this, "Reloading...", Toast.LENGTH_SHORT).show(); } },skipIds);
// Show progress layout, hide all main views progressLayout.showLoading(); progressLayout.showEmpty(ContextCompat.getDrawable(this, R.drawable.ic_empty), "Empty data"); progressLayout.showError(ContextCompat.getDrawable(this, R.drawable.ic_no_connection), "No connection", "RETRY", new View.OnClickListener() { @Override public void onClick(View view) { Toast.makeText(MainActivity.this, "Reloading...", Toast.LENGTH_SHORT).show(); } });}
- Custom ProgressLayout's attributes```java<com.nguyenhoanglam.progresslayout.ProgressLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/progressLayout" android:layout_width="match_parent" android:layout_height="match_parent" app:emptyContentTextColor="@color/grey" app:emptyContentTextSize="14sp" app:emptyImageHeight="200dp" app:emptyImageWidth="200dp" app:errorButtonTextColor="@color/teal" app:errorButtonTextSize="14sp" app:errorContentTextColor="@color/grey" app:errorContentTextSize="14sp" app:errorImageHeight="200dp" app:errorImageWidth="200dp" app:loadingProgressBarColor="@color/teal" app:loadingProgressBarRadius="100dp" app:loadingProgressBarSpinWidth="8dp"/>
0 0
- android 界面显示ProgressLayout
- Android ProgressLayout:加载页面遮挡耗时操作任务页面
- Android 界面全屏显示
- android中界面显示结构
- 【Android】软件界面全屏显示
- android界面不显示标题栏
- Android-Toast显示图文界面
- 【Android】将欢迎界面或者引导界面全屏化显示
- Android 在程序界面上显示图片
- Android 在程序界面上显示图片
- android 详细信息显示界面的思路
- android 详细信息显示界面的思路
- 如何让Android编辑界面显示出来
- Android Graphical Layout 界面效果不显示
- Android 滑动显示下一层界面
- Android Studio显示可视化编辑界面
- android手机界面动态显示到电脑
- android 输入法界面显示的开关
- Fragment list list Content view not yet created问题
- 第四周 求并联后的电阻
- 哈希表查找不成功时的平均查找长度计算和查找成功时的ASL
- 关于各种无法解析的外部符号问题的相应解决方案
- UITableViewCell下划线对齐方法
- android 界面显示ProgressLayout
- Android跨进程访问资源
- 344. Reverse String
- iOS 关于推送点击推送通知的处理
- 真的会读书吗?
- SQLite外键(Foreign Key) 的使用例子
- 两个变量交换数值,不引入第三变量
- 我的第四个C语言:计算圆柱体的表面积和体积。
- LeetCode笔记:191. Number of 1 Bits