我在代码中创建了ImageButton,
// Create Button
ImageButton imageButton = new ImageButton(mContext);
imageButton.setBackgroundResource(R.drawable.button);
imageButton.setOnClickListener(this);
LayoutParams myParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
addContentView(imageButton, myParams);
我如何在布局的底部绘制它?
答案 0 :(得分:2)
尝试:
LinearLayout.LayoutParams lp= (LinearLayout.LayoutParams)myButton.getLayoutParams();
lp.layout_gravity=Gravity.BOTTOM;
myButton.setLayoutParams(lp);