2012-01-04 28 views
1

を含める:Androidのは、私がこのようなレイアウトを持つレイアウト

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

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

<Button 
    android:id="@+id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="profile" /> 

<Button 
    android:id="@+id/button2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="item" /> 

</LinearLayout > 

問題は、それが唯一のインクルードは一部、現れていないボタンを含む示すことです。インクルードレイアウトを削除すると、ボタンが表示されます。私がここで間違っていることは何ですか?ありがとう。

更新:basicinfoレイアウト:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:orientation="vertical" > 

<ImageView 
    android:id="@+id/imageView" 
    android:layout_width="70dp" 
    android:layout_height="wrap_content" 
    android:src="@drawable/icon"/> 

<LinearLayout 
    android:id="@+id/linearLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_below="@+id/imageView1" 
    android:layout_toRightOf="@id/imageView" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/TextView01" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="2dp" 
     android:text="Name:" /> 

    <TextView 
     android:id="@+id/TextView02" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="2dp" 
     android:text="Catogery:" /> 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="2dp" 
     android:text="Description" /> 

    <TextView 
     android:id="@+id/TextView03" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="2dp" 
     android:text="Owner" /> 
</LinearLayout> 

</RelativeLayout> 
+1

あなたも含まれるレイアウトXMLを投稿することができますか? –

+0

basicinfo xmlファイルも投稿できますか? –

+0

haa ...私はそれがあまりにも多く投稿すると思った。私はとにかくそれを更新します。 – bingjie2680

答えて

3

問題を解決します。基本レイアウトでmatch_parentを使用したからです。私は助けを

android:layout_width="match_parent" 
android:layout_height="match_parent" 

android:layout_width="wrap_content" 
android:layout_height="wrap_content" 

のおかげであることを変更しました。

1

私はlayout_widthとlayout_heightをチェックします。これは主にエラーを表示する点です。

1

含まれているレイアウトは画面の大きさと同じくらい大きいので、ボタンは表示領域外です。このインクルードレイアウトにディメンションを与える必要があります

+0

ラップコンテンツでレイアウトの幅と高さを試してみます。それは動作していないようでした。 – bingjie2680

+0

正確な値... 200ディップなどを入れようとします。 –

+0

include xmlのlinearLayoutに一致する親がまだあることがわかりました...その変更を試みてください... wrap_content ...または150dipなどの値を入れよう –

5

あなたがeampleのファイルlayout_heightや幅などが定義します。

<include layout="@layout/basicinfo"  
android:layout_width="100dp" 
android:layout_height="100dp"/> 
+0

ありがとうございます。固定ディメンションを使用するとデバイス間で良好でない場合があります。 – bingjie2680

+0

はい。あなたが正しいです。 basicinfoファイルに多数のコンテンツが含まれているとします。この場合、メインレイアウトのコンテンツの一部が失われます。もう一つの解決策は、layout_weightを使うことです –

0

変更外側のLinearLayoutの幅と高さfill_parentとも内側にスクロールバーを配置します。使用してマージ

-1

...

としてレイアウトと再利用可能なレイアウト主な問題の

<merge xmlns:android="http://schemas.android.com/apk/res/android"> 

    <Button 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/add"/> 

    <Button 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/delete"/> 

</merge> 

Developer Site

0

つのルートビューとして要素を使用することであることBOTH android:layout_widthandroid:layout_heightが含まれている必要があります。レイアウトが画面に表示されます(たとえば、高さが設定されている場合は、幅も設定せずに無視されます)。

だから、このような何かを行うべきである:

<include 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    layout="@layout/myLayout" /> 
関連する問題