android scrollview滚动条初始位置,Android 中 ScrollView滚动不到最底端的解决方法

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

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

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"

/>

android:layout_width="fill_parent"

android:layout_height="0dp"

android:scrollbars="vertical"

android:fadeScrollbars="false"

android:layout_weight="7">

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"

/>

相关阅读:

0b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值