2014-06-13 1 views
0

안드로이드에서 LinearLayout을 부모 컨테이너의 너비만큼 차지하게하는 방법이 있습니까?LinearLayout을 부모 컨테이너의 퍼센티지 너비에 맞 춥니 다.

.elm { max-width:70%; }

가 어떻게 LinearLayoutAndroid와 같은 효과를 얻을 것입니다 : CSS에서

그것은처럼 보일 수 있습니다?

Defining a percentage width for a LinearLayout?과 같은 질문은 너비의 백분율을 차지하기 때문에 최대 너비를 백분율로 정의하지 않기 때문에 질문과 같지 않습니다.

편집 :

시도 @jungleboys 제안 :

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:weightSum="1.0" > 

    <LinearLayout 
      android:id="@+id/bubble_outerWrapper" 
      android:layout_width="0dp" 
      android:layout_weight="0.7" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" > 
     <LinearLayout 
      android:id="@+id/bubble_wrapper" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" > 

      <TextView 
       android:id="@+id/bubble_textView" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:layout_margin="5dip" 
       android:background="@drawable/bubble_yellow" 
       android:paddingLeft="10dip" 
       android:text="TextViewwwwwwwwwwwwwwwwwwwwwww!" 
       android:textColor="@android:color/primary_text_light" /> 
     </LinearLayout> 
    </LinearLayout> 

</LinearLayout> 

이 작동하지 않는, 다른 사람이 어떤 생각을 가지고 있습니까?

답변

0

이 방법을 시도해보고, 이것이 문제를 해결하는 데 도움이되기를 바랍니다.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 

    <LinearLayout 
     android:id="@+id/bubble_outerWrapper" 
     android:layout_width="0dp" 
     android:layout_weight="0.7" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <TextView 
      android:id="@+id/bubble_textView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_margin="5dip" 
      android:paddingLeft="10dip" 
      android:text="TextViewwwwwwwwwwwwwwwwwwwwwww! TextViewwwwwwwwwwwwwwwwwwwwwww! TextViewwwwwwwwwwwwwwwwwwwwwww! TextViewwwwwwwwwwwwwwwwwwwwwww! TextViewwwwwwwwwwwwwwwwwwwwwww!"/> 
    </LinearLayout> 
    <View 
     android:layout_width="0dp" 
     android:layout_weight="0.3" 
     android:layout_height="1"/> 
</LinearLayout> 
관련 문제