Hi, I dont know, what I did till now, now all working fine..
I got the input from this link http://developer.android.com/guide/samples/ApiDemos/src/com/example/android/apis/app/MenuInflateFromXml.html the code I am working is, layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(30, 10, 0, 0); TextView tv = new TextView(this); tv.setText("Sample text"); layout.addView(tv, layoutParams); setContentView(layout); Thanks On Nov 19, 10:42 am, Nithin <[email protected]> wrote: > 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 <[email protected]> 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 <[email protected]> wrote: > > > > any idea.... > > > > On Nov 18, 12:23 pm, Nithin <[email protected]> wrote: > > > > > Padding can't do. I want to implement margin, itself. > > > > > On Nov 18, 12:09 pm, GPU <[email protected]> wrote: > > > > > > use the padding > > > > > > On Nov 18, 10:20 am, Nithin <[email protected]> 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 <[email protected]> wrote: > > > > > > > > anybody know this.. I googled alot, but cant get the exact thing.. > > > > > > > > Thanks > > > > > > > > On Nov 17, 6:45 pm, Nithin <[email protected]> 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 [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

