2011-08-27 158 views
0

的底部畫我的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); 

怎樣繪製它在佈局的底部?

+0

你使用哪種佈局包含按鈕? – Snicolas

+0

我有視圖佈局 –

回答

2

嘗試:

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

我沒有看到lp –

+0

裏面的layout_gravity你將不得不嘗試2種方法,看看哪些工作。 myButton.setGravity();或者lp.gravity = Gravity.BOTTOM。 – blessenm