i am trying to get the Button to the Bottom-Left. Why won’t this work ? I tried for 2 hours and couldn’t achieve it. 🙁
RelativeLayout rl = new RelativeLayout(this);
RelativeLayout.LayoutParams firstImageParams = new RelativeLayout.LayoutParams(
android.view.ViewGroup.LayoutParams.MATCH_PARENT,
android.view.ViewGroup.LayoutParams.MATCH_PARENT);
Button b = new Button(this);
b.setText("take photo");
b.setGravity(Gravity.BOTTOM | Gravity.LEFT);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "Select Area of Interest", Toast.LENGTH_SHORT).show();
}
});
rl.addView(mGrabView,firstImageParams);
rl.addView(b);
rl.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
this.addContentView(rl,new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
You’ll need to add layout parameters to the button instead of gravity.