动漫网站开发 sh框架,镇江网站制作教程,建立网站的详细步骤,网站导航栏三根横线怎么做的Android 解决 NestedScrollView 底部内容被遮挡显示不全很早之前就遇到过在使用 NestedScrollView 的时候发现底部的 View 总是显示不全, 看起来像是被底部的什 padding 遮挡了一样.这次是一个 recycleView, 在 list 没有数据的时候总是显示不全, 有数据的时候就正常了. 子类控…Android 解决 NestedScrollView 底部内容被遮挡显示不全很早之前就遇到过在使用 NestedScrollView 的时候发现底部的 View 总是显示不全, 看起来像是被底部的什 padding 遮挡了一样.这次是一个 recycleView, 在 list 没有数据的时候总是显示不全, 有数据的时候就正常了. 子类控件高度都设置了 wrap_content, 还是没效果. 以前都是直接在最下面的子控件加一个合适的 layout_marginBottom.. 今天刚好比较闲就决定找到原因, 解决, 也方便以后查阅.解决方案NestedScrollView 加一句Android:fillViewporttrue完美解决哈哈原理出现这个问题感觉应该是 NestedScrollView 的测量方法去找原因OverrideprotectedvoidonMeasure(intwidthMeasureSpec,intheightMeasureSpec){super.onMeasure(widthMeasureSpec,heightMeasureSpec);if(!mFillViewport){return;}finalintheightModeMeasureSpec.getMode(heightMeasureSpec);if(heightModeMeasureSpec.UNSPECIFIED){return;}if(getChildCount()0){ViewchildgetChildAt(0);finalNestedScrollView.LayoutParamslp(LayoutParams)child.getLayoutParams();intchildSizechild.getMeasuredHeight();intparentSpacegetMeasuredHeight()-getPaddingTop()-getPaddingBottom()-lp.topMargin-lp.bottomMargin;if(childSizeintchildWidthMeasureSpecgetChildMeasureSpec(widthMeasureSpec,getPaddingLeft()getPaddingRight()lp.leftMarginlp.rightMargin,lp.width);intchildHeightMeasureSpecMeasureSpec.makeMeasureSpec(parentSpace,MeasureSpec.EXACTLY);child.measure(childWidthMeasureSpec,childHeightMeasureSpec);}}}看到这里, mFillViewport, 字面意思填充, 如果是 false 被 return 出去,if(!mFillViewport){return;}看文档说明/*** When set to true, the scroll view measure its child to make it fill the currently* visible area.*/privatebooleanmFillViewport;翻译过来设置为 true 时, 滚动视图将测量其子级以使其填充当前 * 可见区域.默认值为 false, 果然没有重新测量 , 所以在 xml 添加设置为 true 就解决了来源: https://blog.csdn.net/qq_39178733/article/details/105391159