分享一個(gè)頁(yè)面加載狀態(tài)布局
public class LyLoadingLayout extends FrameLayout {
public final static int Success = 0;
public final static int Empty = 1;
public final static int Error = 2;
public final static int No_Network = 3;
public final static int Loading = 4;
private int mState;
private Context mContext;
private View loadingPage;
private View errorPage;
private View emptyPage;
private View networkPage;
private View defineLoadingPage;
private ImageView errorImg;
private ImageView emptyImg;
private ImageView networkImg;
private TextView errorText;
private TextView emptyText;
private TextView networkText;
private TextView errorReloadBtn;
private TextView networkReloadBtn;
private View contentView;
private OnReloadListener listener;
//是否一開(kāi)始顯示contentview今妄,默認(rèn)不顯示
private boolean isFirstVisible;
//配置
private static Config mConfig = new Config();
private static String emptyStr = "暫無(wú)數(shù)據(jù)";
private static String errorStr = "請(qǐng)求錯(cuò)誤谱轨,請(qǐng)重試";
private static String netwrokStr = "找不到網(wǎng)絡(luò)";
private static String reloadBtnStr = "點(diǎn)擊刷新";
private static int emptyImgId = R.drawable.empty_com;
private static int errorImgId = R.drawable.empty_com;
private static int networkImgId = R.drawable.default_no_network;
private static int reloadBtnId = R.drawable.verify_shape_main;
private static int tipTextSize = 14;
private static int buttonTextSize = 14;
private static int tipTextColor = 0xff999999;
private static int buttonTextColor = 0xff999999;
private static int buttonWidth = -1;
private static int buttonHeight = -1;
private static int loadingLayoutId = R.layout.widget_loading_page;
public LyLoadingLayout(Context context, AttributeSet attrs) {
super(context, attrs);
this.mContext = context;
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LoadingLayout);
isFirstVisible = a.getBoolean(R.styleable.LoadingLayout_isFirstVisible, false);
a.recycle();
}
public LyLoadingLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.mContext = context;
}
public LyLoadingLayout(Context context) {
super(context);
this.mContext = context;
}
/**
* contentView 當(dāng)加載完成xml后執(zhí)行
*/
@Override
protected void onFinishInflate() {
super.onFinishInflate();
if (getChildCount() > 1) {
throw new IllegalStateException("LyLoadingLayout can host only one direct child");
}
contentView = this.getChildAt(0);
if (!isFirstVisible) {
contentView.setVisibility(View.GONE);
}
build();
}
private void build() {
loadingPage = LayoutInflater.from(mContext).inflate(loadingLayoutId, null);
errorPage = LayoutInflater.from(mContext).inflate(R.layout.widget_error_page, null);
emptyPage = LayoutInflater.from(mContext).inflate(R.layout.widget_empty_page, null);
networkPage = LayoutInflater.from(mContext).inflate(R.layout.widget_nonetwork_page, null);
defineLoadingPage = null;
networkPage.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
netwrokStr = "重新加載";
errorText = findViewById(errorPage, R.id.error_text);
emptyText = findViewById(emptyPage, R.id.empty_text);
networkText = findViewById(networkPage, R.id.no_network_text);
errorImg = findViewById(errorPage, R.id.error_img);
emptyImg = findViewById(emptyPage, R.id.empty_img);
networkImg = findViewById(networkPage, R.id.no_network_img);
errorReloadBtn = findViewById(errorPage, R.id.error_reload_btn);
networkReloadBtn = findViewById(networkPage, R.id.no_network_reload_btn);
errorReloadBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (listener != null) {
listener.onReload(v);
}
}
});
networkReloadBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (listener != null) {
listener.onReload(v);
}
}
});
errorText.setText(errorStr);
emptyText.setText(emptyStr);
networkText.setText(netwrokStr);
errorText.setTextSize(tipTextSize);
emptyText.setTextSize(tipTextSize);
networkText.setTextSize(tipTextSize);
errorText.setTextColor(ContextCompat.getColor(mContext, tipTextColor));
emptyText.setTextColor(ContextCompat.getColor(mContext, tipTextColor));
networkText.setTextColor(ContextCompat.getColor(mContext, tipTextColor));
errorImg.setImageResource(errorImgId);
emptyImg.setImageResource(emptyImgId);
networkImg.setImageResource(networkImgId);
errorReloadBtn.setBackgroundResource(reloadBtnId);
networkReloadBtn.setBackgroundResource(reloadBtnId);
errorReloadBtn.setText(reloadBtnStr);
networkReloadBtn.setText(reloadBtnStr);
errorReloadBtn.setTextSize(buttonTextSize);
networkReloadBtn.setTextSize(buttonTextSize);
errorReloadBtn.setTextColor(ContextCompat.getColor(mContext, buttonTextColor));
networkReloadBtn.setTextColor(ContextCompat.getColor(mContext, buttonTextColor));
if (buttonHeight != -1) {
errorReloadBtn.setHeight(dp2px(mContext, buttonHeight));
networkReloadBtn.setHeight(dp2px(mContext, buttonHeight));
}
if (buttonWidth != -1) {
errorReloadBtn.setWidth(dp2px(mContext, buttonWidth));
networkReloadBtn.setWidth(dp2px(mContext, buttonWidth));
}
this.addView(networkPage);
this.addView(emptyPage);
this.addView(errorPage);
this.addView(loadingPage);
}
/**
* 改變視圖加載狀態(tài) 需要手動(dòng)觸發(fā)
*
* @param state
* @param mLyLoadingLayout
*/
public void setLoadViewState(int state, LyLoadingLayout mLyLoadingLayout) {
if (mLyLoadingLayout == null) return;
if (state != mLyLoadingLayout.getStatus()) {
mLyLoadingLayout.setStatus(state);
}
}
/**
* 設(shè)置當(dāng)天狀態(tài)
*
* @param status Success:加載成功;Loading:加載中;
* Empty:數(shù)據(jù)為空;Error:加載失敗
* No_Network:無(wú)網(wǎng)絡(luò)
*/
public void setStatus(@Flavour int status) {
this.mState = status;
switch (status) {
case Success:
animateVisible(contentView);
emptyPage.setVisibility(View.GONE);
errorPage.setVisibility(View.GONE);
networkPage.setVisibility(View.GONE);
if (defineLoadingPage != null) {
animateGone(defineLoadingPage);
} else {
animateGone(loadingPage);
}
break;
case Loading:
contentView.setVisibility(View.GONE);
emptyPage.setVisibility(View.GONE);
errorPage.setVisibility(View.GONE);
networkPage.setVisibility(View.GONE);
if (defineLoadingPage != null) {
animateVisible(defineLoadingPage);
} else {
animateVisible(loadingPage);
}
break;
case Empty:
contentView.setVisibility(View.GONE);
animateVisible(emptyPage);
errorPage.setVisibility(View.GONE);
networkPage.setVisibility(View.GONE);
if (defineLoadingPage != null) {
animateGone(defineLoadingPage);
} else {
animateGone(loadingPage);
}
break;
case Error:
contentView.setVisibility(View.GONE);
emptyPage.setVisibility(View.GONE);
animateVisible(errorPage);
networkPage.setVisibility(View.GONE);
if (defineLoadingPage != null) {
animateGone(defineLoadingPage);
} else {
animateGone(loadingPage);
}
break;
case No_Network:
contentView.setVisibility(View.GONE);
emptyPage.setVisibility(View.GONE);
errorPage.setVisibility(View.GONE);
animateVisible(networkPage);
if (defineLoadingPage != null) {
animateGone(defineLoadingPage);
} else {
animateGone(loadingPage);
}
break;
default:
break;
}
}
/**
* View淡入
*/
public void animateVisible(View view) {
if (view == null) return;
view.setAlpha(0f);
view.setVisibility(View.VISIBLE);
view.animate().alpha(1f).setDuration(450).setListener(null);
}
/**
* View 淡出
*/
public void animateGone(final View view) {
if (view == null) return;
view.animate().alpha(0f).setDuration(400).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
view.setVisibility(View.GONE);
}
});
}
/**
* 返回當(dāng)前狀態(tài){Success, Empty, Error, No_Network, Loading}
*
* @return
*/
public int getStatus() {
return mState;
}
/**
* 設(shè)置Empty狀態(tài)提示文本,僅對(duì)當(dāng)前所在的地方有效
*
* @param text
* @return
*/
public LyLoadingLayout setEmptyText(String text) {
emptyText.setText(text);
return this;
}
/**
* 設(shè)置Error狀態(tài)提示文本,僅對(duì)當(dāng)前所在的地方有效
*
* @param text
* @return
*/
public LyLoadingLayout setErrorText(String text) {
errorText.setText(text);
return this;
}
/**
* 設(shè)置No_Network狀態(tài)提示文本场钉,僅對(duì)當(dāng)前所在的地方有效
*
* @param text
* @return
*/
public LyLoadingLayout setNoNetworkText(String text) {
networkText.setText(text);
return this;
}
/**
* 設(shè)置Empty狀態(tài)顯示圖片来吩,僅對(duì)當(dāng)前所在的地方有效
*
* @param id
* @return
*/
public LyLoadingLayout setEmptyImage(@DrawableRes int id) {
emptyImg.setImageResource(id);
return this;
}
/**
* 設(shè)置Error狀態(tài)顯示圖片敢辩,僅對(duì)當(dāng)前所在的地方有效
*
* @param id
* @return
*/
public LyLoadingLayout setErrorImage(@DrawableRes int id) {
errorImg.setImageResource(id);
return this;
}
/**
* 設(shè)置No_Network狀態(tài)顯示圖片,僅對(duì)當(dāng)前所在的地方有效
*
* @param id
* @return
*/
public LyLoadingLayout setNoNetworkImage(@DrawableRes int id) {
networkImg.setImageResource(id);
return this;
}
/**
* 設(shè)置Empty狀態(tài)提示文本的字體大小弟疆,僅對(duì)當(dāng)前所在的地方有效
*
* @param sp
* @return
*/
public LyLoadingLayout setEmptyTextSize(int sp) {
emptyText.setTextSize(sp);
return this;
}
/**
* 設(shè)置Error狀態(tài)提示文本的字體大小戚长,僅對(duì)當(dāng)前所在的地方有效
*
* @param sp
* @return
*/
public LyLoadingLayout setErrorTextSize(int sp) {
errorText.setTextSize(sp);
return this;
}
/**
* 設(shè)置No_Network狀態(tài)提示文本的字體大小,僅對(duì)當(dāng)前所在的地方有效
*
* @param sp
* @return
*/
public LyLoadingLayout setNoNetworkTextSize(int sp) {
networkText.setTextSize(sp);
return this;
}
/**
* 設(shè)置Empty狀態(tài)圖片的顯示與否怠苔,僅對(duì)當(dāng)前所在的地方有效
*
* @param bool
* @return
*/
public LyLoadingLayout setEmptyImageVisible(boolean bool) {
if (bool) {
emptyImg.setVisibility(View.VISIBLE);
} else {
emptyImg.setVisibility(View.GONE);
}
return this;
}
/**
* 設(shè)置Error狀態(tài)圖片的顯示與否同廉,僅對(duì)當(dāng)前所在的地方有效
*
* @param bool
* @return
*/
public LyLoadingLayout setErrorImageVisible(boolean bool) {
if (bool) {
errorImg.setVisibility(View.VISIBLE);
} else {
errorImg.setVisibility(View.GONE);
}
return this;
}
/**
* 設(shè)置No_Network狀態(tài)圖片的顯示與否,僅對(duì)當(dāng)前所在的地方有效
*
* @param bool
* @return
*/
public LyLoadingLayout setNoNetworkImageVisible(boolean bool) {
if (bool) {
networkImg.setVisibility(View.VISIBLE);
} else {
networkImg.setVisibility(View.GONE);
}
return this;
}
/**
* 設(shè)置ReloadButton的文本柑司,僅對(duì)當(dāng)前所在的地方有效
*
* @param text
* @return
*/
public LyLoadingLayout setReloadButtonText(@NonNull String text) {
errorReloadBtn.setText(text);
networkReloadBtn.setText(text);
return this;
}
/**
* 設(shè)置ReloadButton的文本字體大小迫肖,僅對(duì)當(dāng)前所在的地方有效
*
* @param sp
* @return
*/
public LyLoadingLayout setReloadButtonTextSize(int sp) {
errorReloadBtn.setTextSize(sp);
networkReloadBtn.setTextSize(sp);
return this;
}
/**
* 設(shè)置ReloadButton的文本顏色,僅對(duì)當(dāng)前所在的地方有效
*
* @param id
* @return
*/
public LyLoadingLayout setReloadButtonTextColor(@ColorRes int id) {
errorReloadBtn.setTextColor(ContextCompat.getColor(mContext, id));
networkReloadBtn.setTextSize(ContextCompat.getColor(mContext, id));
return this;
}
/**
* 設(shè)置ReloadButton的背景攒驰,僅對(duì)當(dāng)前所在的地方有效
*
* @param id
* @return
*/
public LyLoadingLayout setReloadButtonBackgroundResource(@DrawableRes int id) {
errorReloadBtn.setBackgroundResource(id);
networkReloadBtn.setBackgroundResource(id);
return this;
}
/**
* 設(shè)置ReloadButton的監(jiān)聽(tīng)器
*
* @param listener
* @return
*/
public LyLoadingLayout setOnReloadListener(OnReloadListener listener) {
this.listener = listener;
return this;
}
/**
* 自定義加載頁(yè)面蟆湖,僅對(duì)當(dāng)前所在的Activity有效
*
* @param view
* @return
*/
public LyLoadingLayout setLoadingPage(View view) {
defineLoadingPage = view;
this.removeView(loadingPage);
defineLoadingPage.setVisibility(View.GONE);
this.addView(view);
return this;
}
/**
* 自定義加載頁(yè)面,僅對(duì)當(dāng)前所在的地方有效
*
* @param id
* @return
*/
public LyLoadingLayout setLoadingPage(@LayoutRes int id) {
this.removeView(loadingPage);
View view = LayoutInflater.from(mContext).inflate(id, null);
defineLoadingPage = view;
defineLoadingPage.setVisibility(View.GONE);
this.addView(view);
return this;
}
/**
* 獲取當(dāng)前自定義的loadingpage
*
* @return
*/
public View getLoadingPage() {
return defineLoadingPage;
}
/**
* 獲取全局使用的loadingpage
*
* @return
*/
public View getGlobalLoadingPage() {
return loadingPage;
}
@IntDef({Success, Empty, Error, No_Network, Loading})
@Retention(RetentionPolicy.SOURCE)
public @interface Flavour {
}
public interface OnReloadListener {
void onReload(View v);
}
/**
* 獲取全局配置的class
*
* @return
*/
public static Config getConfig() {
return mConfig;
}
/**
* 全局配置的Class玻粪,對(duì)所有使用到的地方有效
*/
public static class Config {
public Config setErrorText(@NonNull String text) {
errorStr = text;
return mConfig;
}
public Config setEmptyText(@NonNull String text) {
emptyStr = text;
return mConfig;
}
public Config setNoNetworkText(@NonNull String text) {
netwrokStr = text;
return mConfig;
}
public Config setReloadButtonText(@NonNull String text) {
reloadBtnStr = text;
return mConfig;
}
/**
* 設(shè)置所有提示文本的字體大小
*
* @param sp
* @return
*/
public Config setAllTipTextSize(int sp) {
tipTextSize = sp;
return mConfig;
}
/**
* 設(shè)置所有提示文本的字體顏色
*
* @param color
* @return
*/
public Config setAllTipTextColor(@ColorRes int color) {
tipTextColor = color;
return mConfig;
}
public Config setReloadButtonTextSize(int sp) {
buttonTextSize = sp;
return mConfig;
}
public Config setReloadButtonTextColor(@ColorRes int color) {
buttonTextColor = color;
return mConfig;
}
public Config setReloadButtonBackgroundResource(@DrawableRes int id) {
reloadBtnId = id;
return mConfig;
}
public Config setReloadButtonWidthAndHeight(int width_dp, int height_dp) {
buttonWidth = width_dp;
buttonHeight = height_dp;
return mConfig;
}
public Config setErrorImage(@DrawableRes int id) {
errorImgId = id;
return mConfig;
}
public Config setEmptyImage(@DrawableRes int id) {
emptyImgId = id;
return this;
}
public Config setNoNetworkImage(@DrawableRes int id) {
networkImgId = id;
return mConfig;
}
public Config setLoadingPageLayout(@LayoutRes int id) {
loadingLayoutId = id;
return mConfig;
}
}
public int dp2px(Context context, int dip) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dip * scale + 0.5f);
}
public <T extends View> T findViewById(View v, int id) {
return (T) v.findViewById(id);
}
}
布局文件
widget_error_page.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:id="@+id/error_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/empty_com" />
<TextView
android:id="@+id/error_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp"
android:layout_marginTop="10dp"
android:textColor="#999999" />
<TextView
android:id="@+id/error_reload_btn"
android:layout_width="140dp"
android:layout_height="36dp"
android:clickable="true"
android:gravity="center"
android:text="重新加載"
android:textSize="14sp"
android:textColor="#999999" />
</LinearLayout>
widget_loading_page.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:gravity="center"
android:orientation="horizontal"
android:visibility="gone">
<ProgressBar
style="@style/Widget.AppCompat.ProgressBar"
android:indeterminateDuration="1000"
android:indeterminateOnly="true"
android:layout_width="40dp"
android:layout_height="40dp"
android:indeterminateDrawable="@drawable/content_loading"
/>
</LinearLayout>
widget_nonetwork_page.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mLlNoNetwork"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:id="@+id/no_network_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/default_no_network" />
<TextView
android:id="@+id/no_network_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp"
android:textSize="14sp"
android:layout_marginTop="10dp"
android:textColor="#999999"
tools:text="網(wǎng)絡(luò)錯(cuò)誤" />
<TextView
android:id="@+id/no_network_reload_btn"
android:layout_width="140dp"
android:layout_height="36dp"
android:clickable="true"
android:gravity="center"
android:text="重新加載"
android:textSize="14sp"
android:textColor="#999999" />
</LinearLayout>
widget_empty_page.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone"
>
<ImageView
android:id="@+id/empty_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/empty_com"
/>
<TextView
android:id="@+id/empty_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:lineSpacingExtra="4dp"
android:textSize="14sp"
android:textColor="#999999"
/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="LoadingLayout">
<attr name="isFirstVisible" format="boolean" />
</declare-styleable>
</resources>
下面介紹用法
LoadingLayout支持全局配置隅津,對(duì)所有使用到的地方都起效,需要在Application中配置劲室,如下:
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
LyLoadingLayout.getConfig()
.setErrorText("出錯(cuò)啦~請(qǐng)稍后重試伦仍!")
.setEmptyText("抱歉,暫無(wú)數(shù)據(jù)")
.setNoNetworkText("無(wú)網(wǎng)絡(luò)連接痹籍,請(qǐng)檢查您的網(wǎng)絡(luò)···")
.setErrorImage(R.mipmap.define_error)
.setEmptyImage(R.mipmap.define_empty)
.setNoNetworkImage(R.mipmap.define_nonetwork)
.setAllTipTextColor(R.color.gray)
.setAllTipTextSize(14)
.setReloadButtonText("點(diǎn)我重試哦")
.setReloadButtonTextSize(14)
.setReloadButtonTextColor(R.color.gray)
.setReloadButtonWidthAndHeight(150,40);
}
}
由于“加載中”的頁(yè)面呢铆,可能每個(gè)App都不一樣,因此蹲缠,LoadingLayout支持自定義LoadingPage棺克,如下:
LyLoadingLayout.getConfig().setLoadingPageLayout(R.layout.define_loading_page);
同時(shí),為了適應(yīng)個(gè)別界面的“特殊需求”线定,LoadingLayout也支持局部設(shè)置各種屬性娜谊,僅對(duì)當(dāng)前對(duì)象生效,不影響全局斤讥。如下:
LyLoadingLayout loading = (LyLoadingLayout ) findViewById(R.id.loading_layout);
loading.setLoadingPage(R.layout.define_loading_page)
.setEmptyText("暫無(wú)報(bào)告數(shù)據(jù)")
.setErrorText("")
.setNoNetworkText("")
.setErrorImage(R.mipmap.ic_launcher)
.setErrorTextSize(16)
.setReloadButtonText("點(diǎn)我重新加載哦"); //等等
為ReloadButton設(shè)置監(jiān)聽(tīng):
loadingLayout.setOnReloadListener(new LyLoadingLayout.OnReloadListener() {
@Override
public void onReload(View v) {
}
});
設(shè)置顯示的頁(yè)面:
loadingLayout.setStatus(LyLoadingLayout.Loading);//加載中
loadingLayout.setStatus(LyLoadingLayout.Empty);//無(wú)數(shù)據(jù)
loadingLayout.setStatus(LyLoadingLayout.Error);//錯(cuò)誤
loadingLayout.setStatus(LyLoadingLayout.No_Network);//無(wú)網(wǎng)絡(luò)
loadingLayout.setStatus(LyLoadingLayout.Success);//加載成功
最后纱皆,在xml里面使用:
<LyLoadingLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent
app:isFirstVisible="true">
<TextView
android:background="@color/colorPrimary"
android:visibility="visible"
android:gravity="center"
android:textColor="@android:color/white"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="ContentView"/>
</LyLoadingLayout>
注意:
- isFirstVisible屬性用來(lái)控制contentView一開(kāi)始是否隱藏湾趾,由于LoadingLayout原理是在xml渲染完成后在contentView上鋪上三層View,因此派草,一開(kāi)始如果不隱藏搀缠,等contentView渲染完成后調(diào)用: loadingLayout.setStatus(LoadingLayout.Loading); 會(huì)造成界面閃爍的效果,影響體驗(yàn)近迁,因此默認(rèn)將contentView隱藏艺普,所以數(shù)據(jù)加載完成后一定要調(diào)用loadingLayout.setStatus(LyLoadingLayout.Success);,將contentView顯示出來(lái)鉴竭。這樣也能解決未獲取到數(shù)據(jù)的情況下歧譬,被用戶看到雜亂無(wú)章的布局,個(gè)人還是比較喜歡默認(rèn)隱藏contentView搏存;
- 為了方便管理瑰步,LyLoadingLayout只能有一個(gè)直屬子View,類似ScrollView璧眠,添加兩個(gè)直屬子View會(huì)拋出異常throw new IllegalStateException("LyLoadingLayout can host only one direct child");缩焦;