Got it. It's:
_________________________

LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams
(LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(20, 10, 0, 0);

newVL.setLayoutParams(lp);
_________________________

Thanks anyway!


On 5 Dez., 18:44, VBMichi <[email protected]> wrote:
> Hi,
>
> I am creating buttons dynamically by:
>
> ________________________
>
> Button newVL = new Button(this);
> newVL.setId(zaehler);
> newVL.setText(mText);
> newVL.setWidth(280);
> newVL.setBackgroundDrawable(getResources().getDrawable
> (R.drawable.vlbg));
> mStundenplan.addView(newVL);
> _________________________
>
> How can I add marginTop and marginLeft to this button?
> I've tried:
>
> _________________________
>
> LayoutParams lp = new LayoutParams(null);
> lp.topMargin = 10;
> lp.leftMargin = 20;
>
> newVL.setLayoutParams(lp);
> _________________________
>
> but it doesnt work.
> Any ideas?
>
> Regards,
> Michael

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to