2010-11-22 3 views
3

내 화면을 두 부분으로 나누고 싶습니다. LinearLayout이 있고 두 개의 LinearLayouts이 다시 포함되어 있습니다.Android 레이아웃 부문

두 개의 두 부분을 어떻게 나누는가?

+0

를 사용할 수 있습니다. 알게 .. 어떻게 그들을 나누고 싶니? 세로로 (서로 겹쳐서) 또는 가로로 (서로의 측면에 나타남)? – kishu27

답변

8

그냥 추가 :

android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:layout_weight="1" 

을 둘 수 있습니다. layout_weight 매개 변수가 동일하면 공간의 양이 고르게 분배됩니다.

이전 질문에 대한 답변 중 일부만 받아 들여야합니다.

+0

안녕 솔루션 주셔서 감사하지만 두 개의 레이아웃을 나눌 수 없다, 나는 200px로 layout_width 값을 하드 코딩했습니다. 이처럼하고 싶지 않습니다. 예제로 제안하십시오. – ramsbh

+0

이것은 사용자가 수행하는 방법입니다. 너비 너비를 하드 코딩하려면 물론 50 %로 확장되지 않습니다. 그것을 fill_parent로 변경하십시오. – kcoppock

0

이 예제가 도움이되는지 확인하십시오.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    android:id="@+id/rootlinearlayout" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    xmlns:android="http://schemas.android.com/apk/res/android"> 
    <LinearLayout 
     android:id="@+id/linearlayout01" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:orientation="vertical"> 
     <EditText 
      android:id="@+id/et01" 
      android:gravity="center" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="First TextBox" 
      android:textSize="18sp" /> 
    </LinearLayout> 
    <LinearLayout 
     android:id="@+id/linearlayout02" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:orientation="vertical"> 
     <EditText 
      android:id="@+id/et02" 
      android:gravity="center" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Another TextBox" 
      android:textSize="18sp" /> 
    </LinearLayout> 
</LinearLayout> 
+0

안녕하세요, 답장을 보내 주셔서 감사합니다, 나는 두 번째로 수직으로 화면을 나누고 싶습니다, "AnotherTextbox"는 "First Text box"다음에오고 있습니다. 첫 번째 50 %, 50 두 번째로. 어떤 제안? – ramsbh

+0

두 EditText에서 android : layout_height = "match_parent"를 사용해보세요. 이 잘 작동합니다. –

1

일반적으로 나는 이것을 위해 android : layout_weight = "1"을 사용합니다. 또한 테이블 레이아웃을 사용할 수 있습니다.

0

우리는 조각 의 모두 android:layout_width="0dp"android:layout_weight="1"을 사용할 수 있으며 이들의 부모에, 우리는 단지 답변에 대한 응답을 읽을 android:layout_width="fill_parent"