2012-02-20 5 views
2

을 보유한 FrameLayout과 관련된 매우 이상한 문제가 있습니다. 내 레이아웃은 다음과 같습니다 :FrameLayout 레이아웃 여백 문제의 ScrollView

<FrameLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:layout_marginTop="50dp"> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 
    </LinearLayout> 
    </ScrollView> 

    <... 
    /> 
</FrameLayout> 

내가 함께 가지고있는 문제 : ScrollView 태그에 layout_marginTop 속성을. 그것은 다른 장치에 걸쳐 같은 방법을 적용하지 않습니다. 예를 들어, Nexus S (ICS 실행 중)에서는 화면에 약간의 공간을 추가하여 올바르게 해석되지만 Gingerbread를 실행하는 Galaxy S2에서는 화면 상단이 아닌 화면 하단에 공간을 생성합니다.

아이디어가 있으십니까?

감사합니다.

[편집]

  • 이 문제가 3.0보다 낮은 안드로이드 버전을 실행하는 모든 장치에 공통적 인 것으로 보인다.

  • 이전에 FrameLayoutLinearLayout으로 감싸 져 있었기 때문에 의미가없는 추가 속성을 확인해 주셔서 감사합니다.

+0

레이아웃이 까다로울 수 있습니다. FrameLayout에는 'orientation'속성이 없으며, layout_gravity 속성도 아무 효과가없는 LinearLayout의 자식 인 경우가 아니면 예외입니다. 나는 실제로 어떤 일이 진행되는지 보시려면 단색 배경색을 사용 하시길 권합니다 ... 저는 그것이 당신이 생각하는 것이 아닌가 의심합니다. –

+0

@ReubenScratton 실제로 다른 'FrameLayout'의 자식입니다 (언급 했어야합니다). 내가 제안한대로 추가 속성을 모두 제거했습니다. 솔리드 배경색을 사용하여 진행 상황을 확인합니다. 감사. –

답변

1

에 FrameLayout이있는 android:paddingTop="50dp" 대신 android:layout_marginTop="50dp"를 사용해보십시오.

<FrameLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:layout_paddingTop="50dp"> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 
    </LinearLayout> 
    </ScrollView> 

    <... 
    /> 
</FrameLayout> 
1

android:layout_width="match_parent"android:fillViewPort=true

+0

방금 ​​해봤습니다. 아무것도 바뀌지 않았다. –

2

없음 사용 android:layout_gravity="center_vertical"을 시도합니다. 이것은 의미가 없습니다.

대신 android:layout_marginTopScrollViewandroid:paddingTop를 사용하여 고정있는 ScrollView

<FrameLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:paddingTop="50dp"> 
    <ScrollView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical" 
      > 
     <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical" 
       > 
     </LinearLayout> 
    </ScrollView> 
+0

'fill_parent'와'match_parent'는 정확히 같은 것이 아닙니까? 나는 여분의 모든 속성을 제거했다. 'FrameLayout'에서 paddingTop을 추가 해보겠습니다. 고마워요! –

+0

그들은 동일합니다 (http://stackoverflow.com/questions/5761960/what-is-the-difference-between-match-parent-and-fill-parent-property-in-android) –

관련 문제