2012-04-10 5 views
0

나는 다음과 같은 XML이 : I이 버튼의 텍스트에 LINEBREAK이 여전히 존재하는 layout_weight를 설정 한하지만Android 텍스트가 버튼으로 포장되어 있습니다 - 이유는 무엇입니까?

<LinearLayout 
    android:id="@+id/linearLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" > 

    <TextView 
     android:id="@+id/tv1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/verylongtext" android:layout_weight="1000" /> 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="sometext" android:onClick="onClickButton" android:layout_weight="1" /> 

</LinearLayout> 

, 버튼을

sometext

를 표시해야하지만

을 보여줍니다

SOMET

EXT

왜 그런가요? 어떻게 해결할 수 있습니까?

감사합니다.

답변

0

LinearLayout의 방향을 지정하지 않으므로 기본적으로 가로로 설정됩니다. TextViewButton을 압박하고 있습니다. 또한 android:layout_weight을 사용하는 경우 관련 치수에서 레이아웃의 객체를 구속하지 않으려는 경우가 있으므로 "wrap_content"또는 "match_parent"대신 "0px"을 입력하고 가중치에 따라 해당 비례를 결정할 수 있습니다 크기.

+0

버튼의 경우 wrap_content이고 0dp/px 버튼이어야합니다. – AndyAndroid

1

포함 android:singleLine="true" to button xml.

관련 문제