Created
May 6, 2023 07:00
-
-
Save ZZANZU/19cc1dcfc659eb469ea63fb0c9480e64 to your computer and use it in GitHub Desktop.
ViewPager2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A lot of places in code rely on an assumption that the page fills the whole ViewPager2. | |
* | |
* TODO(b/70666617) Allow page width different than width/height 100%/100% | |
*/ | |
private RecyclerView.OnChildAttachStateChangeListener enforceChildFillListener() { | |
return new RecyclerView.OnChildAttachStateChangeListener() { | |
@Override | |
public void onChildViewAttachedToWindow(@NonNull View view) { | |
RecyclerView.LayoutParams layoutParams = | |
(RecyclerView.LayoutParams) view.getLayoutParams(); | |
if (layoutParams.width != LayoutParams.MATCH_PARENT | |
|| layoutParams.height != LayoutParams.MATCH_PARENT) { | |
throw new IllegalStateException( | |
"Pages must fill the whole ViewPager2 (use match_parent)"); | |
} | |
} | |
@Override | |
public void onChildViewDetachedFromWindow(@NonNull View view) { | |
// nothing | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment