Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

兼容RecyclerView和StateView并不撑满Layout空间的情况,并兼容自动居中显示的情况。 #3851

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,31 @@ internal class StateLayoutVH(
).apply {
gravity = Gravity.CENTER
}
rootView.layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT
rootView.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
}else{
if (
stateView.layoutParams is FrameLayout.LayoutParams
&& ((stateView.layoutParams as FrameLayout.LayoutParams).gravity == Gravity.CENTER)
&& stateView.layoutParams.width == FrameLayout.LayoutParams.WRAP_CONTENT
&& stateView.layoutParams.height == FrameLayout.LayoutParams.WRAP_CONTENT){
//兼容stateview.layoutParams原本为空,设置FrameLayout.LayoutParams并居中的情况
rootView.layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT
rootView.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
}else{
//判断stateView宽度,如果不是MATCH_PARENT则把RootView的高度改为WRAP_CONTENT
if (stateView.layoutParams.width == ViewGroup.LayoutParams.MATCH_PARENT){
rootView.layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT
}else{
rootView.layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT
}
//判断stateView高度,如果不是MATCH_PARENT则把RootView的高度改为WRAP_CONTENT
if (stateView.layoutParams.height == ViewGroup.LayoutParams.MATCH_PARENT){
rootView.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
}else{
rootView.layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT
}
}
}

if (isUseStateViewSize) {
Expand Down