我有一个带有scrollView的布局。
如何计算可能的滚动大小?
我想:
(scroll's content desired height) - window.height = (invisible content height)
但是如何获得滚动内容的实际期望高度?
我可以获得所需的scrollView高度。
我看到了这个post,但没有得到计算。
int diff = (view.getBottom() - (getHeight() + getScrollY()));// Calculate
答案 0 :(得分:0)
// 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>