【发布时间】:2014-08-14 12:42:17
【问题描述】:
如何找到该滚动视图的总 Y 或高度?在那个滚动视图中有一个带有 Long text 的简单 TextView 。
这是我的代码:
<ScrollView
android:id="@+id/scroll_data"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/White" >
<TextView
android:id="@+id/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="@string/scroll_text"
android:textAlignment="center"
android:textColor="@color/Black"
android:textSize="30dp"
android:textStyle="bold" />
</ScrollView>
我尝试了什么:
Log.e("ScrollView.FOCUS_DOWN", scrollData.FOCUS_DOWN + ""); ---> Return 120
Log.e("scrollData.getBottom()", scrollData.getBottom() + "");---> Return 0
Log.e("scrollData", scrollData.getMeasuredHeight() + "");---> Return 0
【问题讨论】:
-
使用 getMeasuredHeightAndState() 函数获取高度。
标签: android scrollview