Reputation: 7773
I have a layout like this:
<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 >
the problem is that it only shows the include part,no buttons showing up. if I remove the include layout, buttons will show up. any idea what I am doing wrong here? thanks.
update: the basicinfo layout:
<?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>
Upvotes: 2
Views: 11351
Reputation: 12424
One of the main issues with an include layout is that BOTH android:layout_width
and android:layout_height
must be included or the layout will simply fill the screen (if for instance only the height is set, it will be ignored without setting the width as well).
So something like this should be done:
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="@layout/myLayout" />
Upvotes: 0
Reputation: 3663
Use Merge...
use the element as the root view for the re-usable layout
<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>
Upvotes: -1
Reputation: 4580
Change the outer LinearLayout width and height to fill_parent and also place a scroll bar inside it.
Upvotes: 0
Reputation: 1381
Define your include file layout_height and width for eample:
<include layout="@layout/basicinfo"
android:layout_width="100dp"
android:layout_height="100dp"/>
Upvotes: 5
Reputation: 7773
I fount out the problem. it was because I used match_parent in basic layout. I just changed that from
android:layout_width="match_parent"
android:layout_height="match_parent"
to
android:layout_width="wrap_content"
android:layout_height="wrap_content"
thanks for help.
Upvotes: 3
Reputation: 928
included layout is as big as the screen dimension, so the buttons are outside view area. you need to give dimension to this include layout
Upvotes: 1
Reputation: 681
I would check layout_width and layout_height. This is mostly the point in displaying errors.
Upvotes: 1