我试图让按钮位于左下角。为什么这行不通?我尝试了 2 个小时,但无法实现。:(
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));