Skip to content

Commit 28e9680

Browse files
committed
Measure nav view too
1 parent d0b916f commit 28e9680

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

nestedtouch/src/main/java/mobile/yy/com/nestedtouch/StickyNestedLayout.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import android.widget.Scroller
3232
* 2018/4/8
3333
*/
3434
@Suppress("MemberVisibilityCanBePrivate", "unused")
35-
class StickyNestedLayout : LinearLayout,
35+
open class StickyNestedLayout : LinearLayout,
3636
NestedScrollingChild2,
3737
NestedScrollingParent2 {
3838

@@ -126,11 +126,13 @@ class StickyNestedLayout : LinearLayout,
126126

127127
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
128128
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
129+
val wrapContent = makeMeasureSpec(0, UNSPECIFIED)
129130
val expectContentHeight = makeMeasureSpec(
130131
measuredHeight - navViewHeight - stickyOffsetHeight,
131132
MeasureSpec.AT_MOST
132133
)
133-
measureChildWithMargins(headView, widthMeasureSpec, makeMeasureSpec(0, UNSPECIFIED))
134+
measureChildWithMargins(headView, widthMeasureSpec, wrapContent)
135+
measureChildWithMargins(navView, widthMeasureSpec, wrapContent)
134136
measureChildWithMargins(contentView, widthMeasureSpec, expectContentHeight)
135137
setMeasuredDimension(measuredWidth, measuredHeight)
136138
}

0 commit comments

Comments
 (0)