我有一个布局,里面有一个 scrollView。
如何计算可能的滚动尺寸?
我认为:
(scroll's content desired height) - window.height = (invisible content height)
但是如何让滚动条的内容达到实际需要的高度呢?
我可以得到scrollView的高度,这不是我需要的。
我看到了这个post ,但我没有得到计算结果。
int diff = (view.getBottom() - (getHeight() + getScrollY()));//计算
最佳答案
// you can do it by the following two attributes in xml in scrollview it will scroll
//accroding to the child views it contain
android:animateLayoutChanges="true"
android:orientation="vertical"
//here is the full example
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:animateLayoutChanges="true"
android:orientation="vertical"
tools:context=".fragments.frag1"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bgsecond"
android:layout_marginBottom="40dp"
>
</RelativeLayout>
</ScrollView>
关于android - scrollView 可以滚动多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55908152/