Hi,
I am trying to give margin for Textview, using MarginLayoutParams and
setMargins(), But its not working
The way I am trying is,
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 tv1 = new TextView(this);
tv.setText("Sample text 1");
tv1.setLayoutParams(compParams);
TextView tv2 = new TextView(this);
tv2.setText("Sample text 2");
compParams.setMargins(50, 150, 0, 0);
tv2.setLayoutParams(compParams);
layout.addView(tv1);
layout.addView(tv2);
setContetntView(tv);
// trial 2
compParams.leftMargin=50;
compParams.topMargin=100;
compParams.rightMargin=0;
compParams.bottomMargin=0;
this way also, not working...
Where I am going wrong..
Any idea please
Thanks
Nithin
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en