2010-07-24 6 views
1

LinearLayout 내부의 TextView가 LinearLayout을 더 크게 만듭니다. 나는 나의 스크린 정상 50 %와 바닥 50 %를 나누고 또한 바닥 50 %는 3 개 부품으로 나뉜 시도하고있다. 그래서 저는 총 3 개 (맨 위), 그리고 1, 1, 1 (맨 아래) 총 6 개를했습니다.TextView가 부모 LinearLayout을 확장하지 못하게하려면 어떻게해야합니까?

다음은 그 모습입니다. http://i.imgur.com/3FJSW.jpg

첫 번째 LinearLayout에서 TextView를 제거하자마자 스플릿이 적절합니다. TextView를 맨 위의 LinearLayout 안에 넣으면 맨 위의 LinerLayout이 TextView의 크기만큼 커집니다.

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:background="#cccccc" 
    android:layout_weight="3"> 

하려면 :

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

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:background="#cccccc" 
    android:layout_weight="3"> 
     <TextView 
     android:text="@string/hello" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textColor="#000000" 
     android:layout_weight="1"/> 
</LinearLayout>  

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:background="#aa0000" 
    android:layout_weight="1"> 
</LinearLayout>  

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:background="#00aa00" 
    android:layout_weight="1"> 
</LinearLayout>  

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:background="#0000cc" 
    android:layout_weight="1"> 
</LinearLayout></LinearLayout> 
+0

저는 텍스트 뷰에서 1의 가중치를 사용하면 linearlayout이 텍스트 뷰 높이의 3 배가되도록합니다. textview 가중치를 제거하십시오. – Sephy

답변

1

가에서 텍스트 뷰의 레이아웃을 변경해보십시오 : 그 나던 작품은, 어쩌면 빼앗아 경우

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal" 
    android:background="#cccccc" 
    android:layout_weight="1"> 

"여기

내 코드입니다 오리엔테이션 "도 마찬가지입니다.

관련 문제