Arbitrary positioning icon on a View

by Eric » Tue, 24 Nov 2009 10:32:54 GMT


Sponsored Links
 Hey all,

I'm trying to figure out how to mimic the "badge" functionality of an
iPhone app...in particular, I've got a gridview that has several
icons, and based on the result of an AsyncTask, I'd like to position a
"new" badge hovering over one of the icons.  I've got the icon showing
up using Activity.addContentView but there don't seem to be any
ViewGroup.LayoutParams attributes to control an x/y position where the
new view should be displayed.  The options as I see them:

1) FrameLayout (also no support for offset that I can see)
2) RelativeLayout (can't figure out how to dynamically add a new
ImageView)
3) Create a large, mostly transparent png to handle the offset non-
programmatically
4) Use AbsoluteLayout to specify pixel offsets.

Any other options I'm missing?  I'd really like to avoid using #3
(clunky) or #4 (deprecated)...any way to get #1 or #2 working?  Or is
there another option I'm missing?

--



Arbitrary positioning icon on a View

by Nithin » Tue, 24 Nov 2009 14:21:06 GMT


 Hi Eric,

Try offsetLeftAndRight() and offsetTopAndBottom() on the imageView, to
position it accordingly in the layout. But it is temporary only. Both
these offset will reset in the next layout pass.

Thanks





--


Sponsored Links


Arbitrary positioning icon on a View

by appforce.org » Tue, 24 Nov 2009 15:44:48 GMT


 Hi Eric,

Have you considered changing your adapter to provide the ImageView-s
nested in RelativeLayout-s?

This will let you do getParent().addView() on you icons.

--



Arbitrary positioning icon on a View

by Eric » Wed, 25 Nov 2009 07:58:52 GMT


 Thanks for the replies, guys.  I ended up using View.setPadding (the
temporary nature of the offset* methods was a bit too transitory for
my needs) to set a left/top padding on the ImageView, and it works
like a charm.




--



Arbitrary positioning icon on a View

by Dianne Hackborn » Wed, 25 Nov 2009 08:16:35 GMT


 



Given that you don't know when a layout pass will be needed, this is
probably a bad solution.

There are lots of options with the layout managers -- using relative layout
and specifying the appropriate parameters to position the badge view in the
corner, using a FrameLayout to layer two children on top of each other, etc.

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--



Other Threads

1. How can an app own two langues (English and German)

2009/3/22 Nox <v.beh...@googlemail.com>:
Hi, you should put your strings in string.xml files
values-en/strings.xml
values-de/strings.xml

Check http://developer.android.com/guide/topics/resources/resources-i18n.html
for more info

-- 
Lliane aka Simon Depiets
Epita Promo 2011,42
http://www.lliane.com
A man is smoking with his girlfriend. She angers herself : "don't you
see the warning on the box ?!"
To which the man replies, "I am a programmer. I don't worry about
warnings. I only worry about errors."

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

2. copying my application package to android x86 eeepc running in vmware

Hi,

Alternatively, mount your Android virtual disk with other Linux
virtual machine,
such as Ubuntu VM.

After installing Ubuntu VM, edit the Ubuntu.vmx file to tell your
android image
as second disk. It would look like this;
scsi1.virtualDev = "lsilogic"
scsi1:0.present = "TRUE"
scsi1:0.fileName = "android.img"

Then mount /dev/sdb1 on Ubuntu and copy your-application.apk file to
/mnt/data/app-private or /mnt/data/app.

Hope this helps a bit.





--~--~---------~--~----~------------~-------~--~----~
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

3. local_manifest.xml problem with release-1.0

4. "Refund some money" uninstalls app

5. Center on webpage

6. How to check if there are registered broadcast listeners?

7. Getting a complete list of android native drawables