› WRAP_CONTENT › an exact number (e.g.,100dp) ViewGroup.LayoutParams MeasureSpec › UNSPECIFIED › EXACTLY › AT MOST For a child view to be measured, two specifications are required:
public static int chooseSize(int spec, int desired, int min) { final int mode = View.MeasureSpec.getMode(spec); final int size = View.MeasureSpec.getSize(spec); switch (mode) { case View.MeasureSpec.EXACTLY: return size; case View.MeasureSpec.AT_MOST: return Math.min(size, Math.max(desired, min)); case View.MeasureSpec.UNSPECIFIED: default: return Math.max(desired, min); } }
public static int chooseSize(int spec, int desired, int min) { final int mode = View.MeasureSpec.getMode(spec); final int size = View.MeasureSpec.getSize(spec); switch (mode) { case View.MeasureSpec.EXACTLY: return size; case View.MeasureSpec.AT_MOST: return Math.min(size, Math.max(desired, min)); case View.MeasureSpec.UNSPECIFIED: default: return Math.max(desired, min); } }
public static int chooseSize(int spec, int desired, int min) { final int mode = View.MeasureSpec.getMode(spec); final int size = View.MeasureSpec.getSize(spec); switch (mode) { case View.MeasureSpec.EXACTLY: return size; case View.MeasureSpec.AT_MOST: return Math.min(size, Math.max(desired, min)); case View.MeasureSpec.UNSPECIFIED: default: return Math.max(desired, min); } }
not be restricted, and its height would be the total height of all child view items and the paddings (if any). In other words, all child view items will be rendered at once.
a RecyclerView inside a NestedScrollView. Instead, use a single RecyclerView with multiple view types to achieve complex UI. › Use an exact height value instead of WRAP_CONTENT for the RecyclerView.
a RecyclerView inside a NestedScrollView. Instead, use a single RecyclerView with multiple view types to achieve complex UI. › Luckily LINE client has its own customized adapter called RecyclerViewModelAdapter to easily support multiple view types in a RecyclerView. › Use an exact height value instead of WRAP_CONTENT for the RecyclerView.
RecyclerView’s height inside a NestedScrollView, all list view items would rendered at once. › Discussed how a RecyclerView inside a NestedScrollView is measured.
RecyclerView’s height inside a NestedScrollView, all list view items would rendered at once. › Discussed how a RecyclerView inside a NestedScrollView is measured. › DO NOT put a RecyclerView inside a NestedScrollView unless the height is known in advance.
here? › Present view controller works on keyboard › Still can take advantage of the powerful UIPropertyAnimator inside UIViewControllerTransitioningDelegate
here? › Present view controller works on keyboard › Still can take advantage of the powerful UIPropertyAnimator inside UIViewControllerTransitioningDelegate › No need to handle hitTest(_:with:)
here? › Present view controller works on keyboard › Still can take advantage of the powerful UIPropertyAnimator inside UIViewControllerTransitioningDelegate › No need to handle hitTest(_:with:) › Can handle background dimming logic and device rotation easily in UIPresentationController
and disappear using transition coordinator Define two states enum State { case expanded, collapsed } transitionCoordinator?.animate(alongsideTransition: { [weak self] (_) in self?.configUI(.expanded) }, completion: nil)
presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? › Define final layout of presented view controller › Add an extra view to do dimming background
Presentation Controller Create an Interactive Animator › The easiest way to create an interactive animator is to subclass UIPercentDrivenInteractiveTransition class and add gesture recognizer event-handling code to your subclass func interactionControllerForPresentation(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? func interactionControllerForDismissal(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning?
view controllers › Sync status when start expanding and end collapsing struct ViewState { let contentOffset: CGPoint } protocol ViewStateSyncDelegate { var initialViewStateForExpandedViewController: ViewState { get } func expandedViewDidFinishCollapsing(_ viewState: ViewState) }