Hi Justin,

setPadding(), will just move the contents of textView, not the widget
itself, unlike margin. Margin will move the widget itself. Beacuse of
that, i am looking for setMargins() itself.

Thanks

On Nov 19, 8:13 am, Justin Anderson <[email protected]> wrote:
> I've never done layout-type stuff programmatically.  I've always done it via
> XML.
>
> However, I noticed that TextView has a setPadding method.  I know it isn't
> exactly the same thing as the margin, but in a lot of cases you can get the
> desired look using either.
>
> ----------------------------------------------------------------------
> There are only 10 types of people in the world...
> Those who know binary and those who don't.
> ----------------------------------------------------------------------
>
> On Wed, Nov 18, 2009 at 7:30 PM, Nithin <[email protected]> wrote:
> > 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]<android-beginners%[email protected]>
> > For more options, visit this group at
> >http://groups.google.com/group/android-beginners?hl=en
>
>

-- 
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

Reply via email to