2011-10-08 7 views
10

<include> 태그를 사용하여 Android 애플리케이션에서 일부 레이아웃 구성 요소를 재사용하려고합니다.layout_weight 속성의 <include> 태그

  1. 포트 : 나는 다른 포트 및 토지 레이아웃을 가지고

    <LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp"> 
    
        <include layout="@layout/calc_equals_button" a:layout_weight="4"/> 
        <include layout="@layout/calc_display"/> 
    
    </LinearLayout> 
    
  2. 토지 :

    <LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp"> 
    
        <include layout="@layout/calc_equals_button"/> 
        <include layout="@layout/calc_display"/> 
    
    </LinearLayout> 
    

주요 차이점은 a:layout_weight="4", 그래서 내가 원하는 내 calc_equals_button 구성 요소가 포트 방향이 더 작아야합니다. 하지 - 내가 그렇지 않으면 직접 모든 확인을 작동 calc_equals_button 구성 요소, 예컨대 :

<LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp"> 
     <DirectionDragButton 
       xmlns:a="http://schemas.android.com/apk/res/android" 
       a:id="@+id/equalsButton" 
       a:text="=" 
       a:layout_width="match_parent" 
       a:layout_height="match_parent" 
       a:layout_weight="4" 
       style="@style/control_button_style" 
       a:onClick="numericButtonClickHandler"/> 

     <include layout="@layout/calc_display"/> 

    </LinearLayout> 

를 삽입하려고하면

것은입니다. 여기

이 calc_equals_button.xml의 샘플입니다 :

<DirectionDragButton 
    xmlns:a="http://schemas.android.com/apk/res/android" 
    a:id="@+id/equalsButton" 
    a:text="=" 
    a:layout_width="match_parent" 
    a:layout_height="match_parent" 
    style="@style/control_button_style" 
    a:onClick="numericButtonClickHandler"/> 

답변

26

의 전류 제한은 당신이 다른 layout_에 대한 layout_width와 layout_height 지정해야한다는 것입니다 * 적용 할 속성.

+0

ICS에서 "현재"와 같이 변경됩니까? –

+0

그러나 문제가 어떻게이 문제를 해결할 수 있습니까? –

+0

@MichellBak 아니요,이 제한 사항은 여전히 ​​ICS에 있습니다. –