2012-06-07 1 views
0

은의 다음과 같은 레이아웃을 세로 모드 800x1280 픽셀의 장치를 가정 해 봅시다 :ScrollView를 회전하는 동안 요소의 종횡비를 변경하는 방법은 무엇입니까?

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/MyScrollView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true" 
    android:scrollbars="none" 
    android:fadingEdgeLength="0dip" > 
    <LinearLayout 
     android:id="@+id/MyLinearLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" > 
    </LinearLayout> 
</ScrollView> 

및 안드로이드 로를 : configChanges = "오리엔테이션"매니페스트 활동에을.

동적 I는 폭 = MATCH_PARENT 및 높이 = getWindowManager(). getDefaultDisplay()의 레이아웃 MyLinearLayout 두 차일 뷰를 추가한다. getHeight(). 그래서 두 아이 사이를 수직으로 스크롤 할 수 있습니다. 각 아이는 전체 화면을 차지합니다.

이제 장치가 가로 방향으로 움직이면 자식의 너비는 MATCH_PARENT 특성으로 인해 원본 800에서 늘어나는 1280의 크기가됩니다.

원래 세로 1280의 고정 된 높이로 작성 되었기 때문에 세로로 늘어나 있지 않습니다. 높이 1280을 유지합니다.

이 뷰를 세로로 늘이는 적절한 방법은 무엇입니까?

width = MATCH_PARENT 및 height = 2048 (1280 * 1280/800)으로 onConfigurationChanged 내부의 child.setLayoutParams를 시도하면 예외가 발생합니다.

답변

0

나는 동적으로 인스턴스화 된 CanvasView (S-Pen SDK의) 하위 작업을하고 있습니다. 나는 this answer의 도움으로 내가 원하는 것을 할 수있었습니다. 내가 com.samsung.sdraw.CanvasView을 inherented 내가 원하는 방식으로 종횡비를 유지 된 onMeasure를 오버라이드, 그리고 콘텐츠가, 스트레칭 해결하기 위해 각 자녀 setEnableZoom (false)를를 호출 할 필요가있다

화면 경계 밖으로 나가는 가로 모드에서 내용을 두 배로 늘리고있었습니다.

관련 문제