2011-10-08 10 views
10

<include>タグを使用して、アンドロイドアプリケーションのレイアウトコンポーネントを再利用しようとしています。私は別のポートと土地のレイアウトを持っている: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コンポーネントのポート方向が小さくなるようにします。ません - 私は、そうでない場合は、直接、すべてがOKに動作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

「Current」はICSで変更されますか? –

+0

これがどのように問題に役立つのでしょうか? –

+0

@MichellBakいいえ、この制限はまだICSにあります。 –

関連する問題