zoukankan      html  css  js  c++  java
  • 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>

  • 相关阅读:
    异步--记录
    css过渡——实现元素的飞入飞出
    使用touch操作图片
    .net mvc中epplus导出excel
    html无卡顿动画实现——requestAnimationFrame
    调用手机摄像头并上传图片--jquery ajax
    jquery form表单赋值封装
    记录
    .net mvc 使用 aspose.cells导出数据
    explain简介
  • 原文地址:https://www.cnblogs.com/blosaa/p/6261908.html
Copyright © 2011-2022 走看看