你好,游客 登录 注册 搜索
背景:
阅读新闻

Android 中 ScrollView滚动不到最底端的解决方法

[日期:2013-11-01] 来源:Linux社区  作者:zhouy1989 [字体:大 中 小]

在用ScrollView包裹TextView时发现。滚动条有时候滚动不到最底端,原因是在TextView中设置了Android:layout_marginTop="20dp",导致marginTop之后,scrollView初始显示的位置向下移动了20dp,你如果想要让他正常显示,必须在代码里面设置一下scrollView的初始显示位置就可以了。mScrollView.smoothScrollTo(0,0).

当然可以去掉TextView的marginTop,在它上面的组件设置layout_marginBottom也是OK的,这样ScrollView中的内容就可以完全显示了,代码如下

 <ImageView
            android:id="@+id/contentImage"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_marginTop="3dp"
            android:layout_weight="3"
            android:layout_marginBottom="10dp"
            android:background="@android:color/transparent"
          />

        <ScrollView
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:scrollbars="vertical"
    android:fadeScrollbars="false" 
    android:layout_weight="7">
        <TextView
            android:id="@+id/newsContent"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="20sp"
            android:text="@string/content"
            android:textColor="@android:color/black"
     
        />
        </ScrollView>

相关阅读:

ScrollView中嵌套ListView滚动效果冲突问题解决 http://www.linuxidc.com/Linux/2013-03/80240.htm

Android自定义ScrollView实现反弹效果【附源码】 http://www.linuxidc.com/Linux/2012-03/56007.htm

Android 下拉刷新控件之ScrollView版本实现 http://www.linuxidc.com/Linux/2012-02/53143.htm

Android基础教程:ScrollView和ListView套用冲突的解决方法 http://www.linuxidc.com/Linux/2011-11/47429.htm

Android开发:ScrollView/HorizontalScrollView常用技巧 http://www.linuxidc.com/Linux/2011-09/43135.htm

更多Android相关信息见Android 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=11

linux
相关资讯       Android ScrollView 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款