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

동일 weight인데 결과가 달려지는 이유는 뭘까요?

0 추천

우선 관심가지고 제 질문을 읽어주셔서 감사합니다.

 

핸드폰 종류가 바뀌어도 영향을 받지 않는 화면을 구성하려고 아래와 같이 weight를 줬습니다.

그런데 동일 weight라도 text의 양에 따라 폭이 달라집니다. 이유를 도저히 모르겠어서 전문가님들의 조언 부탁드립니다.

 


ㅇ 결과

- 화면의 윗 쪽과 아랫 쪽은 모두 같은 weight를 준 것인데 결과가 달라요.... ㅠ.ㅠ

수행 결과


ㅇ activity_main.xml

<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:orientation="horizontal"
             android:layout_width="fill_parent"              
             android:layout_height="wrap_content"
             android:layout_weight="50"
             >

                  <LinearLayout
                      android:layout_width="wrap_content"
                      android:layout_height="fill_parent"
                      android:layout_weight="20"
                      />
                  <TextView
                      android:background="#409090"
                      android:layout_width="wrap_content"
                      android:layout_height="fill_parent"
                      android:layout_weight="60"
                      android:textSize="20dip"
                      android:text="1"
                      />
                  <LinearLayout
                      android:layout_width="wrap_content"
                      android:layout_height="fill_parent"
                      android:layout_weight="20"
                      />
         </LinearLayout>

         <LinearLayout
             android:orientation="horizontal"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:layout_weight="50"
             >

                  <LinearLayout
                     android:layout_width="wrap_content"
                     android:layout_height="fill_parent"
                     android:layout_weight="20"
                     />
                  <TextView 
                     android:background="#409090"
                     android:layout_width="wrap_content"
                     android:layout_height="fill_parent"
                     android:layout_weight="60"
                     android:textSize="20dip"
                     android:text="12345678901234567890"
                      />
                  <LinearLayout
                     android:layout_width="wrap_content"
                     android:layout_height="fill_parent"
                     android:layout_weight="20"
                      />
         </LinearLayout>
</LinearLayout>

익명사용자 님이 2013년 10월 11일 질문
2013년 10월 11일 수정

1개의 답변

0 추천
wrap_content 대신 0dip 로 해보시면 어떻게 되나요?

그리고~ 중첩 weight는 성능에 좋지 않아요~
익명사용자 님이 2013년 10월 11일 답변
wrap_content 대신 0dip로 하니 같아졌습니다.

답변 감사드립니다.
...