2011-03-09 5 views
0

목표는 화면의 한 줄에 6 개의 이미지 (1 이미지, 6 번)를 표시하는 것입니다. 내 접근 방식은 LinearLayout 내부에 RelativeLayout을 중첩시키는 것이 었습니다. 내 문제는 내가 '초상화'모드에있을 때 모든 이미지를 볼 수 없다는 것입니다. 이미지 크기를 조절할수록 이미지가 더 잘 맞을 수 있습니다. 그러나 나는 더 작아지기를 원하지 않습니다. 나는 기본적으로 그것이 맞지 않는 것을 감쌀 것이라고 추측했지만, 그럴 수는 없다. Theres는 자동 크기에 맞지 않는다? 또한 각 이미지간에 얼마나 많은 공간이 수동으로 결정될 수 있습니까? 감사!LinearLayout 내부에 중첩 된 RelativeLayout 내부의 ImageViews

답변

0

기본적으로 두 개의 서로 다른 xml 파일을 세로로, 가로로 한 번 Providing Resources에서 제공해야합니다. 안드로이드는 방향에 따라 적절한 xml 파일을 선택합니다.

res/layout-land/main.xml 

<?xml version="1.0" encoding="utf-8" ?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal"> 
    <ImageView 
     android:id="@+id/debris_view" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:scaleType="fitCenter" 
     android:weight="1" 
     android:src="@drawable/image1" 
    </ImageView 
    ... repeat 5 more times ... 
</LinearLayout> 

weight 요소 모두 적합해야하지만 scaleType와 충돌이있을 수 있습니다

ImageView.ScaleType는 다른 스케일링 스타일

여기

내가 제안 무엇을 설명합니다. 어쨌든이 초상화를 위해, 당신의 조경을 위해 그것을해야, 당신은 너무 이미지의 두 행이 있었다 만들 수 중 하나, 또는 당신은 아래 horizontalScrollView을 사용할 수

res/layout-port/main.xml 

<?xml version="1.0" encoding="utf-8" ?> 
<HorizontalScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
    <LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal">   
     <ImageView 
      android:id="@+id/debris_view" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:scaleType="fitCenter" 
      android:weight="1" 
      android:padding="15dp" 
      android:src="@drawable/image1" 
     </ImageView 
     ... repeat 5 more times ... 
    </LinearLayout> 
</HorizontalScrollView>  

정말, 당신이 prolly 단지 초상화를 사용할 수 있습니다 main.xml을 유일한 레이아웃 파일로 사용하고 방향에 관계없이 가로로 스크롤해야합니다. 당신은 내가 직장에서 오전 weight 내가 위의이 같은까지 각 요소 사이의 공간으로, 당신은 android:padding을 사용 horizontalScrollView

와 얼마나 잘 작동하는지 확실하지 메신저로 세로 main.xml에 몇 번을 변경해야 할 수도 있습니다.

관련 문제