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. Use of 3rd party game engines

I'm looking at building a game for Android and I've looked around for any
sort of insight into how to approach it.  I've run across a few game engines
for the platform and I'm wondering if any of you have had experience in
using them.  I worry about spending a lot of time building an app that
relies heavily on a game engine, that maybe is abandoned at some point or
becomes incompatible with future versions of Android.  However, some of the
"out of the box" functionality appears to be nice to have.  Just curious to
hear if any of you have looked into this at all.

http://rokonandroid.com/index.php
http://www.andengine.org/blog/

--
Chris Stewart
http://chriswstewart.com

Fantasy 
Football<http://chriswstewart.com/android-applications/fantasy-football/>-
Android app for fantasy football fanatics and MFL owners
Social Updater<http://chriswstewart.com/android-applications/social-updater/>-
An easy way to send your status blast to multiple social networks

-- 

2. Creating new calendar event not setting OnActivityResult params

I am trying to use the built-in Calendar Activity to create a new
event.

The code i use to start a new calendar event activity is below.

 Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
startActivityForResult(intent, PICK_OR_CREATE_EVENT);

 The problem i am having is that the OnActivityResult method called
after saving the event has a resultcode of Activity.CANCELLED even
though the Save button was clicked and a new event was created. Also,
the Intent data param is null, which should have been the Uri to the
newly created event.


Does anyone know why the OnActivityResult behaves this way?


Thanks
Kris

-- 

3. FTP Application for IPv6

4. Changing default location of R.java

5. dynamically creating custom checkbox

6. Slider devices cause Activi ties to reset鈥

7. Exception in the bowels of Contact Manager?