imageButton在布局的底部绘制

时间:2011-08-27 21:25:03

标签: android draw imagebutton

我在代码中创建了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);

我如何在布局的底部绘制它?

1 个答案:

答案 0 :(得分:2)

尝试:

LinearLayout.LayoutParams lp= (LinearLayout.LayoutParams)myButton.getLayoutParams(); 
lp.layout_gravity=Gravity.BOTTOM; 
myButton.setLayoutParams(lp);