2012-01-18 5 views
2

これは、基本的なXMLファイルなぜLinearLayoutがこのように見えるのですか(要素間の空白)?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:orientation="vertical" 
       android:background="@color/white" 
     > 
    <!--top part--> 
    <include layout="@layout/top" android:layout_width="fill_parent" 
      android:layout_height="0dp" android:layout_weight="1"/> 

    <!--content area--> 
    <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:layout_weight="5" 
      android:background="#ff6600" 
      > 

    </LinearLayout> 

    <!--bottom part--> 
    <include layout="@layout/bottom" android:layout_width="fill_parent" 
      android:layout_height="0dp" android:layout_weight="1"/> 
</LinearLayout> 

である私はエミュレータでそれをロードすると、それは下の画像上のように見えます。

Weird display

私が間違って何をしているのですか?


EDIT

これは、上部と下部のXMLです。基本的にも。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
     > 
    <ImageView 
      android:id="@+id/bottom_image" 
      android:layout_height="fill_parent" 
      android:layout_width="fill_parent" 
      android:adjustViewBounds="true" 
      android:src="@drawable/bottom" 
      /> 
</LinearLayout> 
----------------------------------------------------------- 
<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
     > 
    <ImageView 
      android:id="@+id/top_image" 
      android:layout_height="fill_parent" 
      android:layout_width="fill_parent" 
      android:adjustViewBounds="true" 
      android:src="@drawable/top" 
      /> 

+1

あなたのトップとボトムのレイアウトも投稿してください。 –

+0

私はそれをしました!それは何かを伝えますか? – sandalone

+0

あなたは9パッチイメージを使用していますか? 'android:adjustViewBounds =" true "' –

答えて

6

これはあなたの問題を解決しますMain.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" 
      android:background="#000000" 
    > 
<!--top part--> 
<include layout="@layout/top" android:layout_width="fill_parent" 
     android:layout_height="wrap_content"/> 

<!--content area--> 
<LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:background="#ff6600" 
     > 

</LinearLayout> 

<!--bottom part--> 
<include layout="@layout/bottom" android:layout_width="fill_parent" 
     android:layout_height="wrap_content"/> 
</LinearLayout> 

ついに

<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/bottom" 
    > 
<ImageView 
     android:id="@+id/bottom_image" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:adjustViewBounds="true" 
     android:src="@drawable/bottom" 
     android:scaleType="fitXY"/> 
</LinearLayout> 

とを

Top.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/top" 
    > 
<ImageView 
     android:id="@+id/top_image" 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     android:adjustViewBounds="true" 
     android:src="@drawable/top" 
     android:scaleType="fitXY"/> 
</LinearLayout> 

Bottom.xmlを、次の試してみてください

+0

私はFitXYを使用することができ、私はちょうど別の方法があるかと思った – sandalone

1

上位と下位の部品からandroid:layout_weightを削除(およびコンテンツ領域で、0とは異なるあなたが欲しいもの、に設定します)。このようにして、コンテンツはすべての利用可能な領域を占有します。

あなたは何をしていたのでしょうか?コンテンツでは、使用可能なスペースの5/7を取るように指示しました。画面の割合に応じて表示されます。

+0

なぜ-1? – Guillaume

+0

私はlayout_weightが必要です。それはそれなしにはできません。 – sandalone

+0

上部と下部のドロワブルのサイズは固定されていますか?そうであれば、固定サイズのイメージを可変サイズのレイアウトに入れます(ウェイトのため)。実際には、予想される動作は – Guillaume

0

実際のスマートフォンでは?スペースもありますか? SDKプラットフォームツールの最新バージョンをお持ちですか?

+0

があることを確かめてください。同じように同じ – sandalone

0

layout_bottomとlayout_topの定義を確認します。おそらくこれらのレイアウトにはmarginTopとmarginBottomが設定されています。

+0

彼らはそうではありません。私はそれらを添付しました。あなたはそれを見ることができます – sandalone

関連する問題