views:

639

answers:

3

I just updated my app and I am getting some odd complaints from people who update it. I am only getting complaints from people with non-stock android phones (phones that manufacturers have modified...HTC phones, cliq, pulse, etc), other phones like the Droid, Nexus work fine. My app (Photo Frame Deluxe) has a list in it with a Image View, Text View, View (spacer) and checkbox, all in a row. What happens on the affected phones is that the rows start overlapping and it cuts the top half of everything off. My layout code for this is below, I am pulling my hair out on this, what might I have wrong in this layout. Why does this work on some phones and not on others? Any help would be appreciated.

Row Layout:

<?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:orientation="horizontal">
<ImageView
    android:id="@+id/photorowIcon"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:paddingTop="10dp"
    android:paddingBottom="10dp"
    android:paddingRight="5dp"
    />
<TextView
    android:id="@+id/photorowText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    />
<View
    android:layout_width="0px"
    android:layout_height="wrap_content"
    android:layout_weight="1"/>
<CheckBox
    android:id="@+id/photorowCheckBox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:focusable="false"
    android:focusableInTouchMode="false"
    />  
</LinearLayout>

Layout Row is inserted in:

<?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">
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/title1_gradient"
    android:orientation="vertical">
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Select Photos to Display:"
    android:textSize="20sp"
    android:textStyle="bold"
    android:textColor="#FFFFFFFF"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    android:paddingTop="5dp"
    />
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/folderName"
    android:textSize="15sp"
    android:textStyle="bold"
    android:textColor="#FFFFFFFF"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    android:paddingBottom="5dp"
    />
    <View
        android:layout_width="fill_parent"
        android:layout_height="1px"
        android:background="#406C6C6C"/>
    </LinearLayout>
<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="0px"
    android:layout_weight="1"
    android:drawSelectorOnTop="false"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    />
<LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_gravity="bottom">    
    <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layout_gravity="bottom"
            android:background="#FF6C6C6C" 
            android:padding="5dp">
            <Button
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:id="@+id/ok"
                android:text="OK"/>
    </LinearLayout>
</LinearLayout>
</LinearLayout>
A: 

I will not be able to pinpoint your problem, but I do know that layouts (unfortunately!) can change between minor versions of Android. I saw a few problems just going from 1.5 to 1.6, specifically with layouts in a list. Even more problematic was the fact that the emulator did not emulate this properly, which makes this very hard to fix. I remember it having to do with gravity, so I would play around with that part. Also, try using a RelativeLayout as thats less resource-hungry than nested linearlayouts.

Also try using the the layout tools from the SDK, layoutopt and Hiearhcy Viewer.

sandos
A: 

change ur listView tag attribute

android:layout_height="fill_parent"
Praveen Chandrasekaran
A: 

I had the same problem. It was evident on 2 Verizon Eris, and in the 1.5 simulator. It does NOT occur in a G1 (v1.6), a moto Droid (2.0.1), or any simulator 1.6+

It occurred within a ListView bound to a ListActivity, and in a vertically oriented LinearLayout. In both cases, I was feeding RelativeLayouts into each, and i kept losing the tops of them

I used the hierarchyViewer, mucked with every damn thing, and spun around. It finally dawned on me, after manually setting minHeight on the RelativeLayout to something larger than what was showing, that the problem wasn't just SIZING, but SHIFTING.. Everything in the RelativeLayout was getting pushed past the top of the view.

This made me mentally revisit sandos's answer above: "something to do with gravity"

in the RelativeLayout (housing each 'row' of the lists), i put:

android:gravity="center_vertical"

this made an enormous difference.

Now, my rows still look narrower in 1.5, but they are usable, and I can keep at it

alienjazzcat