在android中编写布局一般会用到scrollview嵌套LinearLayout,使页面可以自适应其高度。但是有的机型页面可以显示全;有的机型页面显示不全,滚动条怎么也滚动不到底部,如下图所示:


原xml代码:

        android:id="@+id/scrollView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">


                    android:layout_width="fill_parent"
            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:id="@+id/scrollView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">


                    android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
           
android:paddingTop="10dp"
            android:paddingBottom="8dp"

            android:orientation="vertical" >

       


更多相关文章

  1. Android:剖析源码,随心所欲控制Toast显示
  2. js如何判断用户是在PC端和还是移动端访问
  3. 关于真机测试的android选择图片在ImageView上显示,调用setImageBi
  4. Android实现与SQL连接
  5. 谷歌J2ObjC:打破Android应用与iOS应用之间的语言障碍
  6. 关于Android全埋点方案
  7. 《深入探索Android热修复原理》代码热修复总结
  8. Android(安卓)drawable文件夹的使用
  9. android:同时弹出顶部和底部菜单的做法

随机推荐

  1. busybox1.19.3编译错误解决办法
  2. linux用户管理及用户权力下放
  3. 如何在windows 10的linux子系统中启动jup
  4. linux环境下,配置eclipse nodejs开发环境
  5. [置顶] Linux 内核学习(1)
  6. linux下crontab 任务不执行的可能原因总
  7. 第四组内部linux比赛命题
  8. 有种生活态度叫 Linux
  9. Shell编程笔试题
  10. MEMCACHED缓存及状态查看