- ScrollView的實際大小超過手機屏幕的顯示範圍(在Y軸上);如下圖所示,手機屏幕相當於一個滑動窗沿Y軸方向在整個ScrollView中滑動;
- ScrollView只能含有一個子View(當然這View可以是一個Group,如Layout,即可含有多個View);所以,可以這樣理解,這個包含的子View的顯示範圍即ScrollView的全部顯示範圍;
<com.example.photowallfallsdemo.MyScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/first_column"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="@+id/second_column"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="@+id/third_column"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</com.example.photowallfallsdemo.MyScrollView>
myScrollView.getScrollY();
scrollLayout = getChildAt(0);//獲取MyScrollView的唯一一個子View
scrollLayout.getHeight();
c、獲取手機顯示範圍的高度:getHeight();//相對於MyScrollView
示意圖: