2012-06-17 8 views
0

를 작성해야합니다 : 있는 LinearLayout 내가이 레이아웃이 최소 공간

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:gravity="left"> 
    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"> 
     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Some text" /> 
    </LinearLayout> 
    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="TextView"/> 
</LinearLayout> 

그러나 (있는 LinearLayout에서 해당) 첫 번째 텍스트 뷰의 텍스트가 많은 경우, 두 번째 텍스트보기가 화면 밖으로 이동

. 이것은 android : layout_weigh = "1"을 선형 레이아웃으로 설정하면 해결할 수 있습니다. 하지만이 경우에는 선형 레이아웃이 모든 공간을 채울 것이고 선형 레이아웃에서 많은 텍스트를 볼 때 두 번째 텍스트 뷰를 숨기지 않고 짧은 텍스트에 최소 공간을 채우는 선형 레이아웃이 필요합니다.

답변

0

첫 번째 텍스트 뷰가, 두 번째 텍스트 뷰가 화면 밖에서 렌더링 너무 많은 수평 공간을 차지하면 ...

가 화면 밖에서 두 번째 텍스트 뷰 렌더링을 방지하기 위해, 첫 번째 텍스트 뷰의 가로 크기를 제한 할 필요가 . 첫 번째 텍스트 뷰에 고정 된 숫자 값인 android : layout_width를 지정할 수 있습니다. android : singleLine을 false로 설정할 수 있습니다. android : maxWidth를 적절한 값으로 설정할 수 있습니다. (나는이 해결책들을 시도하지 않았지만 그들은 일해야한다).

또는 두 줄 대신 단일 텍스트보기를 사용할 수도 있습니다.

+0

감사합니다. android : maxWidth에 대해 잊어 버렸습니다. – zebraxxl

0

해결책은 첫 번째 TextView를 ScrollView에 놓고 두 번째 TextView를 결코 고정되지 않는 고정 바닥 글에 넣는 것입니다 (이 작업은 with a RelativeLayout 일 수 있음).

첫 번째 TextView에 너무 많은 텍스트가 있으면 두 번째 TextView를 표시하면서 스크롤 할 수 있습니다.

+0

ScrollView가 저에게 적합하지 않습니다. 두 번째 텍스트보기가 항상 표시되어야합니다. 첫 번째 텍스트보기에서 많은 텍스트가 줄 바꿈되어야합니다. – zebraxxl

관련 문제