Thanks Romain, although I'd be interested in any tips on how to get
around that? Would I have to implement my own custom ListView sub-
class, or where should I start?

What I also don't quite understand is why I get the same result even
if I embed a second inner RelativeLayout inside the outer one and set
"wrap_content" on that one as well. Even if it only encloses those two
small TextViews (for which wrap_content does work) it still grows to
fill the parent. It's as if "wrap_content" is overruled by the
ListView for _all_ ViewGroups found in the entire hierarchy of the
list item? What am I missing here?

Thanks
/Henrik

On May 26, 11:51 pm, Romain Guy <[email protected]> wrote:
> List items are always as wide as the ListView.
>
>
>
> On Tue, May 26, 2009 at 2:19 AM, HenrikH <[email protected]> wrote:
>
> > Hi,
>
> > I'm trying to make a list that contains elements not necessarily
> > occupying the entire width of the screen, but even if using
> > android:layout_width="wrap_content" on my elements, they always behave
> > as if their width value were set to "fill_parent" instead.
> > If I set a fixed value for the width, e.g. "100px", that value is
> > indeed used, but I just can't get wrap_content to work.
>
> > Example simple list item:
>
> > <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
> > android"
> >        android:layout_width="wrap_content"
> > android:layout_height="wrap_content"
> >        android:background="#707">
> >                <TextView android:id="@+id/text1"
> >                        android:layout_width="wrap_content"
> > android:layout_height="wrap_content"
> >                        android:layout_alignParentTop="true"
> > android:layout_alignParentRight="true"
> >                        android:background="#770"
> >                        android:text="Text1" />
> >                <TextView android:id="@+id/text2"
> >                        android:layout_width="wrap_content"
> > android:layout_height="wrap_content"
> >                        android:layout_alignParentLeft="true" 
> > android:layout_below="@id/
> > text1"
> >                        android:background="#077"
> >                        android:text="Text2" />
> > </RelativeLayout>
>
> > What am I missing here? How do I accomplish a list item with
> > wrap_content behaviour, i.e., where the width of each RelativeLayout
> > is adapted to the length of the strings in the contained text views?
>
> > BR
> > /Henrik
>
> --
> Romain Guy
> Android framework engineer
> [email protected]
>
> Note: please don't send private questions to me, as I don't have time
> to provide private support.  All such questions should be posted on
> public forums, where I and others can see and answer them
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to