0

I am doing custom layout. But I want to seem like in the screen button, image, text.

See Setting parameters on child views of a RelativeLayout .I want to add a button on the left side. Can anybody help me?

My code is:

RelativeLayout.LayoutParams lp1=new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
addView(pic,lp1);

RelativeLayout.LayoutParams lp2=new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
lp2.addRule(RelativeLayout.RIGHT_OF,pic.getId());
addView(name,lp2);


RelativeLayout.LayoutParams lp3=new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
lp3.addRule(RelativeLayout.LEFT_OF,pic.getId());
addView(deletebutton,lp3);

What is wrong?

Community
  • 1
  • 1
DuyguK
  • 4,250
  • 9
  • 33
  • 46
  • Exactly. What is wrong? You will have to describe your problem in more detail. – Arnab Chakraborty Dec 13 '11 at 09:22
  • i want to see first button second ımageview third textview.But When i do it i cannot see button?I get refered picture.I want to put 2 view left side and right side? – DuyguK Dec 13 '11 at 09:25

1 Answers1

1

Look carefully at what you do.

First, you add "pic" to your layout, which will be aligned with your relative layout on the left side (since you didn't provide any rules for it).

At the end, you are trying to add a view at the left side, but there is no space for it, since your pic is left aligned.

You have couple of ways out.

1) Add rule for a 'pic' to be centered in parent horizontally. The there might be free space on the left to fit button.

2) Add button first (it will be aligned left), then add pic and set rule to be on the buttons' right and then add name like you did.

Alex Orlov
  • 18,077
  • 7
  • 55
  • 44