安卓:滚动型的总高度 [英] Android: Total height of ScrollView

查看:114
本文介绍了安卓:滚动型的总高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义滚动型(扩展android.widget.ScrollView),我在我的布局中使用。我要测量的这种滚动视图的内容物的总高度。的getHeight()和getMeasuredHeight()不给我正确的值(太高号)。

I have a custom ScrollView (extended android.widget.ScrollView) which I use in my layout. I want to measure the total height of the contents of this scrollview. getHeight() and getMeasuredHeight() don't give me correct values (too high numbers).

背景资料:我想确定多远用户滚动。我用onScrollChanged来获取X值,但我需要知道一个百分比,所以我需要的总滚动条的高度。

Background information: I want to determine how far the user has scrolled. I use onScrollChanged to get the X value, but I need to know a percentage so I'll need the total scrollbar height.

非常感谢! 埃里克

推荐答案

一个滚动型总有1个小孩。所有你需要做的就是孩子的高度来确定总高度:

A ScrollView always has 1 child. All you need to do is get the height of the child to determine the total height:

int totalHeight = scrollView.getChildAt(0).getHeight();

这篇关于安卓:滚动型的总高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆