开发者

ListView not showing after using include

开发者 https://www.devze.com 2023-02-19 08:02 出处:网络
I am now adding a header to each of my layouts and am doing it with an include. It has so far been working fine until I got to a listview - the listview now doesn\'t show at all!

I am now adding a header to each of my layouts and am doing it with an include. It has so far been working fine until I got to a listview - the listview now doesn't show at all!

<?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:background="#FFFFFF">
    <LinearLayout xmlns:android="http://schemas开发者_运维问答.android.com/apk/res/android"
          android:layout_width="fill_parent"
            android:layout_height="fill_parent">
        <include android:id="@+id/headerbar" layout="@layout/header"
                android:layout_height="wrap_content" android:layout_width="fill_parent" /> 
        <ListView android:id="@+id/android:list"
          android:layout_weight="1"
              android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
        <TextView android:id="@+id/android:empty"
              android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/nothin"/>
    </LinearLayout>
    </ScrollView>

I've also tried giving a height of 0dp but this hasnt worked either. Does anyone have any ideas?

Edit: heres whats being included:

<LinearLayout android:id="@+id/header"
    android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/headerbg"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <ImageButton 
        android:id="@+id/headerButton"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:src="@drawable/header"
        android:background="@null"></ImageButton>
</LinearLayout>


You need to set the orientation property of your linearlayout so that it knows how to stack your elements!


Isn't it the problem that your header has android:layout_height="fill_parent" thus using the whole screen and no space for the rest? If this is not the case, can you show how you are merging both layouts?

0

精彩评论

暂无评论...
验证码 换一张
取 消