android中关于使用scrollview嵌套LinearLayout,页面滚动条不到底的解决方法
16lz
2021-01-26
在android中编写布局一般会用到scrollview嵌套LinearLayout,使页面可以自适应其高度。但是有的机型页面可以显示全;有的机型页面显示不全,滚动条怎么也滚动不到底部,如下图所示:
原xml代码:
android:layout_width="fill_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:orientation="vertical" >
其原因是加了marginTop之后,scrollView初始显示的位置向下移动了10dp,你如果想要让他正常显示,必须在代码里面设置一下scrollView的初始显示位置就可以了。mScrollView.smoothScrollTo(0,0).
可修改代码为下面的就可以了。
正确代码:
android:layout_width="fill_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:paddingTop="10dp"
android:paddingBottom="8dp"
android:orientation="vertical" >
更多相关文章
- Android:剖析源码,随心所欲控制Toast显示
- js如何判断用户是在PC端和还是移动端访问
- 关于真机测试的android选择图片在ImageView上显示,调用setImageBi
- Android实现与SQL连接
- 谷歌J2ObjC:打破Android应用与iOS应用之间的语言障碍
- 关于Android全埋点方案
- 《深入探索Android热修复原理》代码热修复总结
- Android(安卓)drawable文件夹的使用
- android:同时弹出顶部和底部菜单的做法