try setting the layoutparams .setLayoutParams( new LayoutParams(100,40));
When you are creating dynamically its best to set the width and height always. u can also set to WRAP_CONTENT,WRAP_CONTENT etc. On Thu, Apr 15, 2010 at 7:32 AM, grace <[email protected]> wrote: > hi, > > i tried creating the layout dynamically in the oncreate of the > activity > my code looks some thing like this.. > > mLinearLayout_no_button = new LinearLayout(this); > > mLinearLayout_no_button.setOrientation(1); ///---1.for > orientation to be vertical > > > mLinearLayout_no_button.setBackgroundResource(R.drawable.andy); > mEditText_number = new EditText(this); > mEditText_number.setWidth(200); ///--2.width of > the > edit text > mEditText_number.setText(str); > mLinearLayout_no_button.addView(mEditText_number); > mButton_dial = new Button(this); > mButton_dial.setText("Dial!"); > > mButton_dial.setWidth(100); ///---3.width of the dial > button > > mLinearLayout_no_button.addView(mButton_dial); > mButton_dial.setOnClickListener(new View.OnClickListener() { > public void onClick(View v) { > performDial(); > } > > so,if my layout is in default mode i.e, horizontal then lines 2 &3 > work. > and if i change my layout to vertical,then am not able to set the > width to any.. > both the edit text and button are filling the parent. > > why is it like this?? > cant we set attributes to the widgets dynamically?? > plz help.. > > > thanks in advance, > > Grace. > }); > > > -- > 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]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > > To unsubscribe, reply using "remove me" as the subject. > -- 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

