[英]How to scroll programatically a ScrollView?
我對ScrollView有一點問題。 我有一個使用ScrollView進行的活動的布局。 此滾動視圖包含兩個ListView。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rootViewGroup" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:scrollbars="vertical">
<LinearLayout android:orientation="vertical"
android:gravity="top" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="@drawable/cmb_bg">
<ListView android:id="@+id/accountsListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:scrollbars="none" />
<ListView android:id="@+id/cardsListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:scrollbars="none" />
</LinearLayout>
在我的活動的onCreate
方法中,我根據其內容計算ListViews的高度。
在執行期間,在活動啟動時,ScrollView已經滾動了一點。
因此,我嘗試在onCreate的末尾調用方法scrollTo(0, 0)
,但是它沒有任何改變。
有任何想法嗎?
啊! 刪除ScrollView並在活動中僅保留一個ListView。 如果您想在ONE listView中包含不同的內容,請修改適配器或更改UI,但是永遠不要將不同的可滾動容器放在同一屏幕上/彼此內部,這是相關的文章。 http://groups.google.com/group/android-developers/browse_thread/thread/e7c8df374fe31733#從理論上講,您可以在屏幕上拍兩個listview,但希望情況會很奇怪。 我真的會使用分隔符或擴展器或僅使用一個ListView重新設計它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.