2011-10-26 5 views
0

私は2つのLinearLayoutsとボタンを相対レイアウト内に持っています。トップバー(画面の約20%)の約(画面の大半を占めるscrollviewの要素のtop、center、bottom要素を持つレイアウトを設定するにはどうすればよいですか?


ロットで

AのLinearLayout 60: 彼らは次のようになります。画面の%)


私はこれを試みた

底画面の(約20%)にあるボタン:

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <LinearLayout 
    android:id="@+id/layoutTopBlack" 
    android:layout_alignParentTop="true" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
    <include layout="@layout/top_black_bar_cancel_register_button"/> 
</LinearLayout> 

    <LinearLayout 
    android:id="@+id/layoutCenter" 
    android:layout_below="@id/layoutTopBlack" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <include layout="@layout/top_black_bar_cancel_register_button"/> 
</LinearLayout> 

    <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:id="@+id/buttonNextStep" 
    android:text="@string/next_step" 
    style="@style/mainButtonStyle"/> 

</RelativeLayout> 

これは機能しません。レイアウトセンターがボタンの上に横たわっているので、ボタンが表示されることはありません。

提案がありますか?

ありがとうございます。

編集: 私は編集者からこれを見つけた: ジャストボタンの上に自分自身をレイアウトするために、あなたのlayoutCenterを伝えるリソース@のID/layoutTopBlack

答えて

0

を解決できませんでした、このような何か:

<LinearLayout 
android:id="@+id/layoutCenter" 
android:layout_above="@id/buttonNextStep" 
android:layout_below="@id/layoutTopBlack" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
<include layout="@layout/top_black_bar_cancel_register_button"/> 
</LinearLayout> 
+0

私は@ + id/ – Ikky

+0

@Ikkyでリソースを追加したにもかかわらず、リソース@ id/layoutTopBlackを解決できませんでした。どのようにリソースを解決できなかったことで問題を解決しましたか?私は通常、@ + id /でリソースを動かすだけで動作します。 –

0

実際には、言及したパーセンテージを考えれば、にはlayout weightsを使用し、RelativeLayoutは使用しないことをお勧めします。

EGあなたが言及した20%/ 60%/ 20%の重量行うには:トップ/ボトムバーはちょうどrenamそして、その内容を保持する一定の割合を取るないようにする必要がある場合は

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 
    <View android:layout_height="0px" android:layout_weight="1" ... /> 
    <View android:layout_height="0px" android:layout_weight="3" ... /> 
    <View android:layout_height="0px" android:layout_weight="1" ... /> 
</LinearLayout> 

を。 antuneさんの答えはうまくいくはずです。あるいは、上記のようなLinearLayoutを使用することができますが、上/下の棒グラフを設定しないでコンテンツをラップします。次に、中央のビュー上の任意のウェイトは、fill_parentのようにボタンを拭き取ることなく、利用可能な残りのスペースをすべて埋めるようにします。

関連する問題