본문 바로가기
Android Dev

[안드로이드] ScrollView안에 ListView 스크롤하기!

by 필팔청춘 2013. 3. 27.

스크롤뷰(ScrollView)안에 리스트뷰(ListView)를 넣어서 구현하고 싶은데 잘 안되죠...?

아래 처럼하면되요. java소스를 잘보세요~!




scrollview_inner_listview.xml

    <ScrollView

        android:id="@+id/main_box_scrollview"

        android:layout_width="fill_parent"

        android:layout_height="0dp"

        android:layout_weight="1"

        android:background="#e9edee"

        android:visibility="visible" 

        android:scrollbars="none"

        android:fillViewport="true">

 <LinearLayout

                android:layout_width="fill_parent"

                android:layout_height="wrap_content"

                android:orientation="vertical" >

<ListView

                    android:id="@+id/main_box_text_listview"

                    android:layout_width="fill_parent"

                    android:layout_height="210dp"

                    android:cacheColorHint="#00000000"

                    android:choiceMode="none"

                    android:clickable="false"

                    android:focusable="false"

                    android:focusableInTouchMode="false"

                    android:longClickable="false" />

</LinearLayout>

</ScrollView>




ScrollViewInnerListView.java

main_box_text_listview.setOnTouchListener(new OnTouchListener() {

public boolean onTouch(View v, MotionEvent event) {

main_box_scrollview.requestDisallowInterceptTouchEvent(true);

return false;

}

});






참고 : http://icesetting.wordpress.com/2012/01/31/scrollview%EC%95%88%EC%97%90-listview%EB%84%A3%EC%96%B4%EC%84%9C-%EC%8A%A4%ED%81%AC%EB%A1%A4-%EC%95%88%EB%90%A0%EB%95%8C/#comment-3