안드로이드 개발 질문/답변
(글 수 45,052)
...
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="130dip"
android:layout_marginLeft="10dip"
>
<ScrollView
android:layout_width="300dip"
android:layout_height="200dip"
android:background="#000000"
>
<RelativeLayout
android:id="@+id/graphframe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
</RelativeLayout>
</ScrollView>
</FrameLayout>
...
릴레이티브 레이아웃안에 뷰클래스를 addView해서 화면에 나타내고 있습니다.
스크롤해야할일이 생겨서 위 처럼 스크롤뷰로 감싸보니 화면이 나타나질 않습니다..
노란색 스크롤뷰부분을 지우면 또 잘나타나구요..ㅠ 이유가 뭘까요?
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="130dip"
android:layout_marginLeft="10dip"
>
<ScrollView
android:layout_width="300dip"
android:layout_height="200dip"
android:background="#000000"
>
<RelativeLayout
android:id="@+id/graphframe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
</RelativeLayout>
</ScrollView>
</FrameLayout>
...
릴레이티브 레이아웃안에 뷰클래스를 addView해서 화면에 나타내고 있습니다.
스크롤해야할일이 생겨서 위 처럼 스크롤뷰로 감싸보니 화면이 나타나질 않습니다..
노란색 스크롤뷰부분을 지우면 또 잘나타나구요..ㅠ 이유가 뭘까요?
2010.08.29 01:44:00
제가 직접해보지는 않아서 모르겠는데 말이죠
그냥 드는 느낌은 위의 layout에서 RelativeLayout의 height가 wrap_content지만, 현재 들어있는 것이 없으므로 0이고
scrollview는 초기화 될때 content의 height를 0으로 잡을 것 같군요.
그리고 relativelayout에 addview를 후에 해주면 relaitvelayout의 크기는 변할텐데 그게 scrollview에 자동으로 영향을 주는지 모르겠네요
만약 content의 height만큼만 보여준다고 봤을때 이것이 변하지 않는다면 안보일수도 있을 것 같습니다.
그래서 scrollview를 찾아보니 requestLayout이라는게 있네요 이걸 불러주면 되지 않을지.. 또는 invalidate도 있네요 .. 이걸로 될렁가요~
직접 해보고 말씀드리고 싶지만 졸려서 이만;; ^^



