On Nov 17, 2: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
1. use FrameLayout.LayoutParams compParams 2. assign gravity to params: compParams.gravity = Gravity.LEFT | Gravity.TOP 3. call tv.setLayoutParams(compParams) *after* setContentView(tv) -- 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