views:

16

answers:

2

When I try to use layout_above to position a view above another view, it can't find the ID if it's not in the same XML file. I'm adding my XML files at run time but I still want to be able to position them relative to eachother. Any suggestions?

A: 

Implement your RelativeLayout.LayoutParams rules in Java and apply them after "adding [your] XML files at run time".

CommonsWare
I don't really know how to do whatever you're suggesting. This is my code for adding the view...View newView = mInflater.inflate(layoutId, mRokonInterfaceView, true);mInterfaceComponents.put(id, mActivity.findViewById(id));What would I do to position it at this point?
Joren
A: 

Ok I figured out how to do what you suggested. This works:

LayoutParams lv = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
lv.addRule(RelativeLayout.ABOVE, R.id.summary_popup);
InterfaceManager.get(InterfaceManager.DONE_CANCEL_BUTTONS).setLayoutParams(lv);

Thanks for pointing me in the right direction. I only wish I could use normal XML attributes.

Joren