2012-10-04 3 views
1

도움이 필요합니다.이 코드가 올바르게 실행되지 않는 이유는 모르겠다. 첫 번째 텍스트보기와 edittext는 50 %의 공백이 있어야하고 두 번째 textview와 edittext는 빈 레이아웃 만 표시하는 반면 50 %는 다른 텍스트를 원한다. 제발 도와주세요너비를 백분율로 정의하십시오.

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:weightSum="1.0" 
    > 
<TextView 
     android:layout_height="wrap_content" 
     android:layout_weight="0.10" 
     android:layout_width="0dip" 
     android:id="@+id/lytner_card_question_text" 
     android:layout_alignParentRight="true" 
     android:gravity="center" 
     android:textSize="20dp" 
    /> 
<ScrollView android:id="@+id/myparentScrollview" 
      android:layout_height="100dp" 
      android:layout_weight="0.40" 
      android:layout_width="0dip" 
      android:layout_toLeftOf="@+id/lytner_card_question_text" 

      > 

<EditText 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/lytner_card_question_etext" 
    android:minHeight="100dp"  
    /> 

</ScrollView> 
<TextView 
    android:layout_height="wrap_content" 
    android:layout_weight="0.10" 
    android:layout_width="0dip" 
    android:id="@+id/lytner_card_answer_text" 
    android:layout_toLeftOf="@+id/myparentScrollview" 
    android:gravity="center" 
    android:textSize="20dp" 

    /> 
<ScrollView android:id="@+id/myparentScrollview1" 
      android:layout_height="100dp" 
      android:layout_weight="0.40" 
      android:layout_width="0dip" 
      android:layout_toLeftOf="@+id/lytner_card_answer_text" 

     > 
<EditText 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/lytner_card_answer_etext" 
    android:minHeight="100dp" 
    /> 
</ScrollView> 

</RelativeLayout> 
+0

사용 채우기 부모를 한 후 모든 뷰에 – Klaasvaak

+0

사용 체중 attribs 속성 weigth 사용합니다. –

답변

1

상대 레이아웃에 가중치를 추가 할 필요가 없습니다. 선형 레이아웃에서만 작동합니다. 상대 레이아웃을 선형 레이아웃으로 변경 한 다음 다시 시도하십시오.

+1

도움을 주셔서 감사합니다 –

0

무게 레이아웃 상대에서 작동하지 않습니다 다음 시도 선형 무게 레이아웃을 변경합니다.

+1

도와 주셔서 감사합니다 –

3

다음 코드는 당신에게 화면의 높이 절반 용기 등이은 LinearLayouts, 각 제공 : 폭

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

    <LinearLayout 
     android:id="@+id/container1" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"></LinearLayout> 

    <LinearLayout 
     android:id="@+id/container2" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 
    </LinearLayout> 

</LinearLayout> 
+1

도움 주셔서 감사합니다 –

관련 문제