I want to add an image view to apper at a particular time with a position that can be set with respect to other text view. How can I do this? Any help would be appreciated.
-
please explain this "on particular time which position can be set with respect to other text view" – Syed Nazar Muhammad Jun 17 '15 at 13:16
3 Answers
You can first create an alarm for that particular time like here
http://justcallmebrian.com/2010/04/27/using-alarmmanager-to-schedule-activities-on-android/
and then in onRecieve Method you can add your image view dynamically, let you want to put your imageView right of the textView and also let the imageView is iv and textView is tv then
ImageView iv = new ImageView(this);
params.addRule(RelativeLayout.RIGHT_OF, tv.getId());
You can refer the link provided here
http://stackoverflow.com/questions/5296959/programatically-add-view-one-below-other-in-relative-layout

- 761
- 1
- 5
- 17
Check out this post: How to create a RelativeLayout programmatically with two buttons one on top of the other?
Explains how to create RelativeLayout params to adjust positioning in a View
Check out this answer already discussed:
create a new RelativeLayout.LayoutParams
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(...)
(whatever... fill parent or wrap content, absolute numbers if you must, or reference to an XML resource)
Add rules: Rules refer to the parent or to other "brothers" in the hierarchy.
lp.addRule(RelativeLayout.BELOW, someOtherView.getId()) lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT)
Just apply the layout params: The most 'healthy' way to do that is:
parentLayout.addView(myView, lp)
Watch out: Don't change layout from the layout callbacks. It is tempting to do so because this is when views get their actual sizes. However, in that case, unexpected results are expected.

- 402
- 5
- 15