检查滚动型比画面/滚动较高 [英] Check if ScrollView is higher than screen / scrollable

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

问题描述

我怎么能检查是否滚动型比屏幕高?当滚动型的内容在屏幕上适合的滚动型不滚动,当它的内容超出屏幕高度,它的滚动。 如何检查在这方面滚动型的条件?

How can I check if a ScrollView is higher than the screen? When the content of a ScrollView fits on the screen, the ScrollView isn't scrollable, when it's contents exceed the screen height it's scrollable. How can I check the condition of a ScrollView in that regard?

推荐答案

这是滚动型,这是私人的code,但可以适于类本身以外使用

This is the code from ScrollView, which is private, but can be adapted to be used outside of the class itself

/**
 * @return Returns true this ScrollView can be scrolled
 */
private boolean canScroll() {
    View child = getChildAt(0);
    if (child != null) {
        int childHeight = child.getHeight();
        return getHeight() < childHeight + mPaddingTop + mPaddingBottom;
    }
    return false;
}

这篇关于检查滚动型比画面/滚动较高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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