tags:

views:

44

answers:

2

Hello,

I need to create a map with items on it (the map consists of a drawable object, which represents a room) and I thought about using buttons with background images for the items so that they are clickable.

I guess the AbsoluteLayout fits here the best, but unfortunately it's deprecated. What layout would you recommend me for this kind of application ? Is there another layout which supports X/Y coordinates ?

+1  A: 

Relative Layout supports X,Y coords -- and that would probably be the best, since you can set the layout relative to the map instead of the screen.

hwrdprkns
A: 

Cool. THanks so much !

Here is the code, if somebody needs it too.

RelativeLayout RL = new RelativeLayout(this);
RL.addView(V, RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); 
Button t = new Button(this);
t.setText("text");
t.setBackgroundResource(R.drawable.test);
int top = 200; //y
int left = 100; //x

RelativeLayout.LayoutParams LP= new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
                                RelativeLayout.LayoutParams.WRAP_CONTENT);
LP.setMargins(left, top, 0, 0); 

t.setLayoutParams(LP);

RL.addView(t);
setContentView(RL);
Nils
No problem, glad I was able to point you in the right direction.
hwrdprkns