• android程序中界面太大太长太宽如何滚动?


    使用ScrollView即可。

     ScrollView只能容纳一个直接的子控件。

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


    原xml代码:

    <ScrollView

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


    <LinearLayout
    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" >

    </LinearLayout>
    </ScrollView>

    其原因是加了marginTop之后,scrollView初始显示的位置向下移动了10dp,你如果想要让他正常显示,必须在代码里面设置一下scrollView的初始显示位置就可以了。mScrollView.smoothScrollTo(0,0). 或 android:paddingTop="10dp"

    可修改代码为下面的就可以了。

    正确代码:

    <ScrollView

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


    <LinearLayout
    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" >

    </LinearLayout>
    </ScrollView>

  • 相关阅读:
    地图校正方法心得
    投影的心得点滴
    android 打包 apk keystore
    scp命令详解
    ubuntu11.10真机调试nopermissions
    android adb server is out of date
    ubuntu删除默认jdk
    android 运行 错误 总结
    android file .apk is not a valid zip file adb install
    ubuntu系统目录结构
  • 原文地址:https://www.cnblogs.com/blosaa/p/6261908.html
Copyright © 2020-2023  润新知