2013-11-04 2 views
1

버튼 옆에 텍스트 필드가 있고 화면 크기에 관계없이 최대 너비 공간을 채우려고합니다. 문제는 다른 화면 크기를 시도 할 때 그 사이의 여분의 공간이 증가한다는 것입니다. 나는이 시도 :Android 선형 레이아웃 DoubleLine

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" > 

    <Button 
    android:id="@+id/btnQuestion" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 

    android:text="@string/Question" /> 

    <EditText 
    android:id="@+id/editText1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="44dp" 
    android:ems="10" 
    android:inputType="number" 
    android:textAlignment="center" > 

    <requestFocus /> 
    </EditText> 

    </LinearLayout> 

을하지만이 발생합니다

http://snag.gy/pzlmP.jpg

그러나입니다 상대적 레이아웃과 공간 증가 크기를 조정할 때 http://snag.gy/VOAuA.jpg

이 내가 orignally 한 것입니다. 콘텐츠를 감싸기로 설정했기 때문이라고 생각하십니까? 어쨌든이 문제를 해결할 수 있다면 감사 할 것입니다!

+0

의도적으로 여백을 넣습니까? –

+0

'화면 크기에 상관없이 최대 너비 공간을 채 웁니다 .' match_parent처럼 보입니까? – njzk2

+0

(귀하의 선형 레이아웃은 수평입니다 ...) – njzk2

답변

0

EditText에는 layout_marginTop이 있지만 Button에는 layout_marginTop이 없습니다. 따라서 EditText의 상단은 컨테이너 상단 (LinearLayout)에서 44dp 오프셋됩니다.

관련 문제