2012-04-09 10 views
1

linearLayoutを使用して画面を分割する際に問題が発生しました。 私のターゲットは9個の물고기に分割されます - LinearLayoutで再生を開始したとき、LinearLayoutを使用して画面を分割する際に問題が発生しました

次のXMLコードで

http://imageshack.us/photo/my-images/4/firstna.png/

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
    <LinearLayout 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_weight="1" 
    android:baselineAligned="false"> 
    <FrameLayout 
     android:gravity="center_horizontal" 
     android:background="#aa0000" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_weight="1"> 
    </FrameLayout> 
    <FrameLayout 
     android:gravity="center_horizontal" 
     android:background="#00aa00" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_weight="4"/> 
    <FrameLayout 
     android:gravity="center_horizontal" 
     android:background="#aaaa00" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_weight="1"/> 
    </LinearLayout> 
    </LinearLayout> 

後、私はそれがラットの変更でframeLayout左にコンテンツを追加しようとしたときに(問題となっている。)このでframeLayoutのIO:次のコードを使用して

http://imageshack.us/photo/my-images/692/secondp.png/

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
    <LinearLayout 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_weight="1" 
    android:baselineAligned="false"> 
    <FrameLayout 
     android:gravity="center_horizontal" 
     android:background="#aa0000" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_weight="1"> 
     <LinearLayout 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:layout_weight="1"> 
<TextView 
    android:text="row one" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1"/> 
<TextView 
    android:text="row two" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1"/> 
<TextView 
    android:text="row three" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1"/> 
<TextView 
    android:text="row four" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1"/> 
    </LinearLayout> 
    </FrameLayout> 
    <FrameLayout 
     android:gravity="center_horizontal" 
     android:background="#00aa00" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_weight="4"/> 
    <FrameLayout 
     android:gravity="center_horizontal" 
     android:background="#aaaa00" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_weight="1"/> 
    </LinearLayout> 
    </LinearLayout> 

私はちょうどlayout_weight属性でレイアウトを制御する能力を持っているしたいと思います - FrameLayoutにコンテンツを追加するとその比率が変更されると、割合が保存される別のコンテナを見つける手助けが必要になります。 ありがとうございました。

答えて

0

あなたはネストされたレイアウトをたくさん使用しています。あなたの左手のレイアウトは、その内部の別の線形レイアウトとすべてのテキストビューを持つフレームレイアウトである必要がありますか?または、FrameLayoutの親を置き換え、背景色を垂直のLinearLayoutに移動できますか?

実際には、なぜ2番目の線形レイアウトも必要ですか?最初の線形レイアウトの向きが水平(それはとにかく高さにfill_parentを持つ)の向きを持っていることを指定してから、2番目のネストされた線形レイアウトをドロップします。

さらに、FrameLayoutsのレイアウト幅を0dpに変更して、ウェイトに基づいて動的にサイズを変更できるようにすることを検討してください。