마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

리니어레이아웃 weight(가중치) 값 세팅 하였는데 왜 이렇게 뜨죠 ?

0 추천
안녕하세요 코딩하다가 책에 적힌내용과 다르게 출력이되서 ...제가 잘못한거진 고수님들한테 여쭙고 싶네요 ...
 
아래 그림에서 
 
노랑에 android:layout_weight="2"
 
파랑에 android:layout_weight="1"
 
을 각각 주었습니다. 
 
제가 생각한대로라면 노랑이 2/3을 차지하고 파랑이 1/3 을 차지해야되는데 ...
 
어찌된건지 ....반대가 되어 출력이 되네요 ...제가 잘못한건지 ..버그인건지 ..고수님 시원한 답변 부탁드립니다.ㅠㅠ
 
아래에 xml 소스도 가치 첨부하였습니다.
 
 
---------------------------------------------------------------------------------------------------------------
xml
---------------------------------------------------------------------------------------------------------------
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="10dp">
	
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#FF0000"
        android:orientation="vertical"
        android:layout_margin="10dp">
    </LinearLayout>
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#00FF00"
        android:orientation="horizontal"
        android:layout_margin="20dp"
        android:baselineAligned="false">
        
        <LinearLayout
            android:layout_width="match_parent"
			android:layout_height="match_parent"
			android:background="#FFFF00"
			android:orientation="vertical"
			android:layout_weight="2"
			android:layout_margin="10dp" >
        </LinearLayout>
        
       <LinearLayout
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			android:background="#0000FF"
			android:orientation="vertical"
			android:layout_weight="1"
			android:layout_margin="10dp">        
        </LinearLayout>
        
    </LinearLayout>

</FrameLayout>

 

 

구구라오 (170 포인트) 님이 2015년 1월 22일 질문

2개의 답변

+1 추천
 
채택된 답변
weight 가 적용된  LinearLayout의

android:layout_width="match_parent" 를

android:layout_width="0dp" 으로 바꾸어  주시면됩니다
psalm (1,910 포인트) 님이 2015년 1월 22일 답변
구구라오님이 2015년 1월 22일 채택됨
psalm 님 궁금증이 시원하게 해결됐네요^^ 감사합니다.
+1 추천
layout_width = 0px

부모레이아웃에 weight_sum=3
기초개발자 (24,060 포인트) 님이 2015년 1월 22일 답변
기초개발자님두 감사드립니다.^^
...