2012-03-20 3 views
1

android : 안드로이드에서 3 개의 다른 크기의 패널로 화면을 분할하는 방법은 무엇입니까?

enter image description here 
과 같은 화면을 만들고 싶습니다.이를 달성하기 위해 몇 가지 코드를 작성합니다.하지만 내가 원하는 것을하지 않았습니다. 텍스트 영역이 화면에 없습니다. 어떻게해야합니까?

Main linear layout with vertical alignment 
add a new linear layout with horizontal alignment 
add a new linear layout with horizontal or vertical alignment 

그래서 첫 번째 레이아웃 (주 레이아웃의 왼쪽 부분)에서 당신이 수평 정렬과 함께 새로운 선형 레이아웃을 추가 : 모든 의견 .. 당신이 할 수

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/linearLayout123" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" 
     android:weightSum="1.0" 
     android:gravity="fill"> 

    <LinearLayout 
     android:id="@+id/linearLayout12" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="top" > 

    <Button android:id="@+id/button1"    
     android:layout_width="wrap_content"           
     android:layout_height="wrap_content"   
     android:text="Hello, I am a Button" /> 

     </LinearLayout> 


    <LinearLayout 
     android:id="@+id/linearLayout2" 
     android:layout_width="118dp" 
     android:layout_height="fill_parent" 
     android:layout_gravity="right" 
     android:orientation="vertical" > 

     <Button android:id="@+id/button2"    
     android:layout_width="wrap_content"           
     android:layout_height="wrap_content"   
     android:text="Hello, I am a Button" /> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/linearLayout1" 
     android:layout_width="228dp" 
     android:layout_height="fill_parent" 
     android:layout_gravity="left" > 

      <TextView 
       android:id="@+id/text2"    
       android:layout_width="wrap_content"    
       android:layout_height="wrap_content"    
       android:text="Hello, I am a TextView" /> 

      </LinearLayout> 


    </LinearLayout> 
+0

구조화 된 LinearLayouts에 뷰를 추가 할 수 있도록하거나, 각 섹션에 하나의 버튼 만 있고 다른 섹션에 하나의 텍스트 뷰만 표시하려는 경우 – dymmeh

답변

6

RelativeLayout의 당신은 LinearLayouts로

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <LinearLayout 
     android:id="@+id/rightLayout" 
     android:layout_width="100dip" 
     android:layout_height="fill_parent" 
     android:layout_alignParentRight="true" 
     android:background="#003300" 
     android:orientation="vertical" > 
    </LinearLayout> 


    <LinearLayout 
     android:id="@+id/topLayout" 
     android:layout_toLeftOf="@id/rightLayout" 
     android:layout_width="fill_parent" 
     android:layout_height="100dip" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:background="#330033" 
     android:orientation="vertical" > 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/bottomLayout" 
     android:layout_toLeftOf="@id/rightLayout" 
     android:layout_below="@id/topLayout" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_alignParentLeft="true" 
     android:background="#334433" 
     android:orientation="vertical" > 
    </LinearLayout> 

</RelativeLayout> 

결과를 원하는 것을 달성 할 것입니다 보여주고 싶은 새로운 선형 레이아웃이나 직접 개체를 추가 번째 레이아웃에서 (주 레이아웃의 오른쪽 부분) 및 (나는 당신이 원하는 확실하지 이후) 버튼/TextViews 등 :

ResultResult2

당신이 multipl을 보유하는 컨테이너로은 LinearLayouts를 사용하는 경우 전자보기 다음 그것을 가지고 그것을 떠난다.

각 "부품"에서 하나의보기 만있을 경우 레이아웃 파일의 LinearLayouts를 해당 유형으로 변경하십시오. Ex. 당신이 할 파트 1을 원한다면 그냥 버튼을

<LinearLayout 
     android:id="@+id/topLayout" 

<Button 
     android:id="@+id/topLayout" 

중첩 된 뷰를 피하기 위해 그래서 그것의 좋은 나쁜 것으로 변경하면 수

이 당신이 원하는 방법에 따라 달라집니다
+0

고맙습니다. 제가 원했던 것입니다. 제가 언급했듯이, 각기 다른 응용 프로그램이 각 패널에있을 것이기 때문에 저는 그것들을 분리하고 싶습니다. 예를 들어 첫 번째 부분에는 애니메이션이 적용된 텍스트가 있고 세 번째 부분에는 사진이나 무언가가있을 것입니다. 나는이 세 가지 레이아웃으로 이런 종류의 응용 프로그램을 만들 수 있다고 생각합니다. – jakobiyem

+0

당신이 말한 것은 모두 잘 작동해야합니다. 행운을 빕니다! – dymmeh

+0

정말 고마워요. :) – jakobiyem

2

.. 사전에 감사합니다 원하는 두 요소를 추가하십시오. 당신은 당신이

+0

잘못 이해하지 못하면 첫 번째와 세 번째 파트가 있어야합니다. 함께. 그러나 나는 각기 다른 응용 프로그램이 각 패널에있을 것이기 때문에 그것들을 분리하려고합니다. 예를 들어, 첫 번째 부분에는 텍스트가 있지만 세 번째 부분에는 사진이 있습니다. – jakobiyem

+0

상대 레이아웃을 사용하지 마십시오. 다른 화면 크기의 기능에서 다를 수 있습니다! 내가 쓴 것을 따라하면 레이아웃에 원하는 것을 추가 할 수 있습니다. – JackTurky