2013-06-14 3 views
2

android : weight 속성을 사용하고 있습니다.LinearLayout에 TextView를 추가 할 때 LinearLayout이 확장됩니다.

첫 번째 상태

http://s1.postimg.org/umygk8han/first.png

<LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="223" 
     android:orientation="horizontal" > 
    </LinearLayout> 

http://s7.postimg.org/89qjb42dn/two.png

<LinearLayout 
    android:layout_width="0dp" 
    android:layout_height="match_parent" 
    android:layout_weight="223" 
    android:orientation="horizontal" > 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:text="Sample" 
     android:textColor="@android:color/background_dark" /> 
    </LinearLayout> 

텍스트 뷰

를 추가는이 문제를 어떻게 해결할 수 있습니까?

안부

+1

공유 레이아웃 코드입니다. –

답변

0

나는 그것이 LinearLayout에 할당에 layout_weight에 좋은 아이디어라고 생각하지 않기 때문에 처음에 당신의 LinearLayoutRelativeLayout 외부가 필요하다고 생각합니다.

그래서 이런 식으로 작업을 수행합니다

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:layout_weight="223" 
    android:orientation="horizontal" > 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:text="Sample" 
     android:maxLines="1" 
     android:textColor="@android:color/background_dark" /> 
</RelativeLayout> 

PS를 : 그것은 나에게 보였다 때문에이 RelativeLayoutandroid:layout_height="0dp"을 설정 (스크린 샷에 따라) 그것은 LinearLayour의 노드로했다 orientation='vertical'

0

내가있는 LinearLayout 인해 텍스트 뷰의 글꼴 크기로 확장 이해, 글꼴 크기를 감소하려고합니다.

<TextView ....  
    android:textSize="9sp" /> 

은 또한 당신은 0

android:padding="0dp" 

희망은 도움에 패딩 텍스트 뷰 설정을 시도 할 수 있습니다!

0

시도에 android:layout_height="match_parent"을 설정하여 TextView

0

android:layout_height="wrap_content"에 울부 짖는 코드를 사용하여보십시오.

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dip" 
    android:layout_weight="1" 
    android:orientation="vertical" 
    android:padding="5dip" 
    android:weightSum="2" > 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="0dip" 
     android:layout_weight="1" 
     android:background="@android:color/white" 
     android:text="Sample" /> 
</LinearLayout> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dip" 
    android:layout_weight="1" 
    android:orientation="vertical" 
    android:padding="5dip" 
    android:weightSum="2" > 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="0dip" 
     android:layout_weight="1" 
     android:background="@android:color/white" 
     android:text="Sample" 
     android:textColor="@android:color/background_dark" /> 
</LinearLayout> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dip" 
    android:layout_weight="1" 
    android:orientation="vertical" 
    android:padding="5dip" 
    android:weightSum="2" > 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="0dip" 
     android:layout_weight="1" 
     android:background="@android:color/white" 
     android:text="Sample" 
     android:textColor="@android:color/background_dark" /> 
</LinearLayout> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dip" 
    android:layout_weight="1" 
    android:orientation="vertical" 
    android:padding="5dip" 
    android:weightSum="2" > 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="0dip" 
     android:layout_weight="1" 
     android:background="@android:color/white" 
     android:text="Sample" 
     android:textColor="@android:color/background_dark" /> 
</LinearLayout> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dip" 
    android:layout_weight="1" 
    android:orientation="vertical" 
    android:padding="5dip" 
    android:weightSum="2" > 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="0dip" 
     android:layout_weight="1" 
     android:background="@android:color/white" 
     android:text="Sample" /> 
</LinearLayout> 

+0

여전히 작동하지 않습니다. – bcb

관련 문제