1
 RelativeLayout overlay = new RelativeLayout(this);
            addContentView(overlay, new LayoutParams(LayoutParams.FILL_PARENT, px));
            overlay.setBackgroundColor(Color.BLACK);


            border = new ImageView(this);
            border.setImageResource(R.drawable.featured_bar);
            border.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

            overlay.addView(border);

I would like to get my border imageview to sit at the bottom of my relativelayout, and programmatically or course.

Basically, I want my decorative border to be at a certain position relative to the resolution, and since I do not know how to position using x y values, I've come to this method.

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
Adam
  • 8,849
  • 16
  • 67
  • 131
  • You can take a help from this [answer][1]. [1]: http://stackoverflow.com/questions/3053864/how-to-center-layout-to-vertical-in-android-through-java-code – Sandy Dec 06 '11 at 05:28

1 Answers1

1

Try something like

RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
overlay.setLayoutParams(params);

Have a look at this post and this one

Community
  • 1
  • 1
momo
  • 3,404
  • 6
  • 37
  • 66