Any idea, how to put margin for widgets... setPadding() wont work in my case. I want the entire widget to move, unlike setPadding. In setPadding(), only contents will move within the widget.
Thanks On Nov 18, 3:26 pm, Nithin <nithin.war...@gmail.com> wrote: > Hi, > > now, I am trying in this, still its not working... > > LinearLayout layout = new LinearLayout(this); > LayoutParams layoutParams = new LayoutParams( > LinearLayout.LayoutParams.FILL_PARENT, > LinearLayout.LayoutParams.FILL_PARENT); > layout.setLayoutParams(layoutParams); > > MarginLayoutParams compParams = new MarginLayoutParams( > LinearLayout.LayoutParams.WRAP_CONTENT, > LinearLayout.LayoutParams.WRAP_CONTENT); > compParams.setMargins(50, 100, 0, 0); > TextView tv = new TextView(this); > tv.setText("Sample text"); > tv.setLayoutParams(compParams); > layout.addView(tv); > setContetntView(tv); > > // trial 2 > > compParams.leftMargin=50; > compParams.topMargin=100; > compParams.rightMargin=0; > compParams.bottomMargin=0; > > tv.setLayoutParams(compParams); > > this way also, not working... > > any idea... > > On Nov 18, 3:10 pm, Nithin <nithin.war...@gmail.com> wrote: > > > any idea.... > > > On Nov 18, 12:23 pm, Nithin <nithin.war...@gmail.com> wrote: > > > > Padding can't do. I want to implement margin, itself. > > > > On Nov 18, 12:09 pm, GPU <gopuraj...@gmail.com> wrote: > > > > > use the padding > > > > > On Nov 18, 10:20 am, Nithin <nithin.war...@gmail.com> wrote: > > > > > > Hi, > > > > > > I tried in this way too, still no success > > > > > > MarginLayoutParams compParams = new MarginLayoutParams > > > > > (MarginLayoutParams.WRAP_CONTENT, > > > > > MarginLayoutParams.WRAP_CONTENT); > > > > > compParams.topMargin=100; > > > > > compParams.leftMargin=100; > > > > > compParams.bottomMargin=0; > > > > > compParams.rightMargin=0; > > > > > > //compParams.setMargins(100, 100, 0, 0); > > > > > TextView tv = new TextView(this) > > > > > tv.setLayoutParams(compParams); > > > > > setContentView(tv); > > > > > > any idea please.. > > > > > > Thanks > > > > > > On Nov 17, 7:58 pm, Nithin <nithin.war...@gmail.com> wrote: > > > > > > > anybody know this.. I googled alot, but cant get the exact thing.. > > > > > > > Thanks > > > > > > > On Nov 17, 6:45 pm, Nithin <nithin.war...@gmail.com> wrote: > > > > > > > > Hi, > > > > > > > > I created a textview and also MarginlayoutParams. Then i put > > > > > > > setMargin > > > > > > > for the MarginLayoutParams and inserted that to textview using > > > > > > > tv.setLayoutparams(), but its not working. > > > > > > > > The code is, > > > > > > > > MarginLayoutParams compParams = new MarginLayoutParams > > > > > > > (MarginLayoutParams.WRAP_CONTENT, > > > > > > > MarginLayoutParams.WRAP_CONTENT); > > > > > > > compParams.setMargins(100, 100, 0, 0); > > > > > > > TextView tv = new TextView(this) > > > > > > > tv.setLayoutParams(compParams); > > > > > > > setContentView(tv); > > > > > > > > But the textView is still in top left corner, its not moving. > > > > > > > > Any suggestions please.. > > > > > > > > Thanks > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en