【问题标题】:how much can a scrollView scroll?scrollView 可以滚动多少?
【发布时间】:2019-04-29 17:23:33
【问题描述】:

我有一个布局,里面有一个滚动视图。

如何计算可能的滚动大小?

我认为:

(scroll's content desired height) - window.height = (invisible content height)

但是如何获得滚动内容的实际所需高度?

我可以得到scrollView的高度,这不是我需要的。

我看到了这个post,但我不明白。

int diff = (view.getBottom() - (getHeight() + getScrollY()));// Calculate

【问题讨论】:

标签: android android-layout layout scroll onmeasure


【解决方案1】:
// 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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-14
    • 2015-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多