[英]ScrollView how to scroll to bottom of another view
How can I scroll a LinearLayout in a ScrollView to the bottom of Another View? 如何将ScrollView中的LinearLayout滚动到另一个视图的底部?
I have a calendar imageview at the top of my view. 我的视图顶部有一个日历图像视图。 Underneath there is a ScrollView that contain a list of events for that month. 下面是一个ScrollView,其中包含该月的事件列表。 The ScrollView contains several LinearLayouts that detail the events for that month. ScrollView包含几个LinearLayout,它们详细说明了该月的事件。 When the user selects an event by touching a button in the linear layout I would like to re-position the current linearlayout to the top of the scrollview, how can I accomplish this? 当用户通过触摸线性布局中的按钮来选择事件时,我想将当前的线性布局重新定位到滚动视图的顶部,我该如何做到这一点?
Below is a brief snippet of what my layout looks like for brevity. 为了简短起见,以下是我的布局的简短摘要。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/cirLinLayContainer"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg_calendar">
<RelativeLayout>
<Button
android:id="@+id/calLeft"
android:background="@drawable/btn_arrowleft_dwn"/>
<Button
android:id="@+id/calRight"
android:background="@drawable/cal_rightnav_button"/>
<ImageView android:src="@drawable/cal_september"
android:layout_width="match_parent"
android:layout_centerHorizontal="true"
android:layout_height="wrap_content" />
</RelativeLayout>
<ScrollView xmlns:foo="http://schemas.android.com/apk/res/com.demo.android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:id="@+id/septemberCalendarScroller">
<LinearLayout android:id="@+id/sepEventLayout01"/>
<LinearLayout android:id="@+id/sepEventLayout02"/>
<LinearLayout android:id="@+id/sepEventLayout03"/>
<LinearLayout android:id="@+id/sepEventLayout04"/>
</ScrollView>
</LinearLayout>
您可以测量linearlayout元素的高度,然后使用ScrollView.scrollTo()相应地定位滚动视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.