0

I am going crazy here. I swear I've had this work a thousand times before and it's like nothing is behaving correctly now. I have to be doing something stupid. A few days ago I was having issues with the background on a list view item not filling the parent to stretch across the height of the list view item. I finally gave up and just hardcoded a height for both to fix that. Now I'm just trying to set a background of an entire activity and have it fill it's parent so that the image covers the entire screen. This activity is within a tab. Here is the code for the tab controller and the activity I'm having issues with.

Tab Layout:

<?xml version="1.0" encoding="utf-8"?>
<TabHost 
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="5dp">

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>

        <FrameLayout
            android:id="@android:id/tabcontent"            
            android:layout_width="fill_parent"            
            android:layout_height="fill_parent">

        </FrameLayout>
</LinearLayout>
</TabHost>

Troublesome Activity:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background">

<RelativeLayout
    android:id="@+id/localHeader"
    android:layout_width="fill_parent"
    android:layout_height="50dip"
    android:background="@drawable/header2">

    <Button
        android:id="@+id/changeCityButton"
        android:layout_width="80dip"
        android:layout_height="30dip"
        android:layout_marginRight="10dip"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:onClick="buttonChangeOnClickListener"
        android:text="Change"
        android:textColor="#FFFFFF"
        android:background="@drawable/local_deal_redeem_button" />

    <TextView
        android:id="@+id/cityName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dip"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
        android:layout_toLeftOf="@id/changeCityButton"
        android:textSize="20dip"
        android:textColor="#FFFFFF"
        android:textStyle="bold"
        android:shadowColor="#FF000000"
        android:shadowDx="1"
        android:shadowDy="1"
        android:shadowRadius="1"/>

</RelativeLayout>

<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@id/localHeader"
    android:fastScrollEnabled="true"
    android:cacheColorHint="#00000000"
    android:divider="@null"
    android:dividerHeight="0px"/>

</RelativeLayout>

This issue appears to only be happening on the new Bionic. the "@drawable/background" will only stretch as high as the listview is long. And if there are no items in the listview it will not show anything. I've even tried ripping it out of the layout and making it just an imageview and that didn't work either. It's like there is a wrap_content tag somewhere that I'm missing. Normally I would just say this is something screwey with the Bionic but seeing as how I had those issues with the ListView background I'm thinking I've got something messed up somewhere. Please help!!

Also in my manifest:

<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:resizeable="true" android:anyDensity="true"></supports-screens>

But I've tried removing that and no matter what values I put in that line it doesn't do anything in my app.

EDIT: I've just realized that if I put the image into a "fill_parent" scrollview the background will stretch accordingly. However since the screen contains a ListView, I cannot go this route. Something is wacky here.

EDIT 2: I just ripped out the listview and it worked perfectly. It is somehow related to the listview.

EDIT 3: I just solved the issue by setting ListView height to "wrap_content". I have no idea why "fill_parent" was causing this behavior on this device, but it is fixed so all is well now. I can't self-answer for another 6 hours so if someone wants to put this as an answer I will select it as correct. Thanks everyone!

2
  • did you try android:scaleType="fitXY"
    – Houcine
    Oct 6, 2011 at 17:13
  • It has to be something related to being inside tabs. I just tried a stand alone activity and it works fine.
    – honeal
    Oct 6, 2011 at 17:28

3 Answers 3

1

I resolved it by setting ListView height to wrap_content. I have no idea why fill_parent was causing this behavior on this phone, but it is now correctly functioning so all is well. Thanks everyone!

0

Try this logic with fragments because tab is now deprecated. This is my view and it canbe wrong also bu once try it man.

3
  • Can afford to redesign the app now. This is the last issue to address before build release.
    – honeal
    Oct 6, 2011 at 17:40
  • but i think your problem is the tab activity which is declared deprecated now
    – Rocker
    Oct 6, 2011 at 18:22
  • The problem was actually the ListView. Just because it is declared deprecated it will not cause it to suddenly stop functioning correctly on previous devices. I certainly appreciate the input and will be implementing Fragments on future builds.
    – honeal
    Oct 6, 2011 at 18:37
0

I was just looking into this very issue, and found this:

http://community.developer.motorola.com/t5/MOTODEV-Blog/Why-Does-My-ListView-Look-Different/ba-p/17462

Basically, the default theme on the Bionic sets android:overScrollFooter on the ListView. Setting it to @null will provide the behavior other devices exhibit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.