How to create a view with a background that wraps up all the content of the view?

by hc » Thu, 05 Mar 2009 17:20:35 GMT


Sponsored Links
 'm trying to create a listview containing conversations in chat
bubbles, and each chat bubbles are rows in the list view.

So what I have is an avatar on the left, and a chat bubble on the
right.
Then in the chat bubble, I have a textview for name, a textview for
content, and a textview for time.

The problem is, I cannot adjust the height of the chat bubble such
that the bottom edge is just below the textview for time. In the
chatBubble, I have this line that does not work
android:layout_alignBottom="@+id/timeLabel"
because timeLabel is a textview created after chatBubble. If I place
chatBubble tags right below timeLabel, the height of chatBubble will
be just right because lf the layout_alignBottom, but chatBubble covers
all the text created before it.

Is there a way I can create the chatBubble last, and bring the view to
the background?
Or is there a better way to do this?


<?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="wrap_content">

<Button android:id="@+id/avatarIcon"
android:background="@drawable/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip" android:layout_marginTop="5dip"/>
<Button android:id="@+id/chatBubble"
android:layout_toRightOf="@+id/avatarIcon"
android:background="@drawable/chat_bubble_left"
android:layout_width="fill_parent"
android:layout_alignBottom="@+id/timeLabel"
android:layout_height="fill_parent"
android:layout_margin="5dip"/>
<TextView android:id="@+id/userLabel"
android:layout_toRightOf="@+id/avatarIcon"
android:text="user name should be here......"
android:textColor="#ff8400"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:textSize="11dip"
android:layout_marginLeft="20dip"/>
<TextView android:id="@+id/content"
android:layout_toRightOf="@+id/avatarIcon"
android:layout_below="@+id/userLabel"
android:text="This is just a test description"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="11dip"
android:layout_marginLeft="20dip"
android:textColor="#fff"
android:layout_marginRight="20dip"
android:layout_marginTop="5dip"/>
<TextView android:id="@+id/timeLabel"
android:layout_alignParentRight="true"
android:layout_below="@+id/reviewContent"
android:text="10 mins"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"



Other Threads

1. Hola

Halo semuanya,
Salam kenal saya anggota baru nih, mo ijin mantau dulu sambil tunggu  
"pesulap" saya dateng minggu depan.

Sent from my iPhone

--~--~---------~--~----~------------~-------~--~----~
Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to id-android@googlegroups.com

To request to subscribe to this group, please visit the following page:
 

2. Video problem - How to use a surface for both canvas and mediaplayer

Hii All

I have a requirement in my application where i need to do 2 things :
1.use canvas to display a bitmap
2.use mediaplayer class to display a video.

I tried using "getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);"
and could see the video alone followed by an exception for  canvas.
This is expected as i am using "SURFACE_TYPE_PUSH_BUFFERS".

But if i dont use 'SURFACE_TYPE_PUSH_BUFFERS' then the video will not
be seen but everythign that i have given for 'canvas' works.

But i need to use both canvas and mediaplayer(for video) in my app.
How can i achieve this?

Or is it possible to create 2 surfaceviews, one for canvas and the
other for mediaplayer.setDisplay() ??

can anybody please share with me the code if they have tried something
like this?

Please show me some path out of this. Any help is greatly appreciated.

thanks in advance,
Latha

--~--~---------~--~----~------------~-------~--~----~

3. can anybody tell pls....

4. Archos 5 Android: new firmware w/ ADB support

5. u can run but u can't hide

6. Custom ANR messages

7. Touchscreen Input event processing in Android