Thursday, April 21, 2011

[android-developers] Re: how to set margin or padding between buttons

The solution was roughly like this -

Button button = (Button)layoutInflater.inflate(R.layout.my_button,
null);
button.setText("foobar");
TableRow.LayoutParams blp = new TableRow.LayoutParams();
blp.leftMargin = buttonMarginDips;
button.setLayoutParams(blp);


On Apr 21, 5:29 pm, jotobjects <jotobje...@gmail.com> wrote:
> Actually it depends on the container the Button is inside of.
> layout_margin* will work if the Button is inside a LinearLayout. When
> I add the Button widget dynamically (addView) to the TableRow is
> doesn't take effect.
>
> To get margins I think I need to do
> button.setLayoutParams(myTableRowLayoutParams)
>
> On Apr 21, 4:21 pm, Mark Murphy <mmur...@commonsware.com> wrote:
>
>
>
> > Button most definitely supports android:layout_margin,
> > android:layout_marginTop, etc.
>
> > On Thu, Apr 21, 2011 at 7:03 PM, jotobjects <jotobje...@gmail.com> wrote:
> > > I have a row of Buttons that are added dynamically to a TableRow in
> > > code.  We are inserting space by creating Views to put between
> > > Buttons.  Is there a lighter weight way to accomplish that? Button
> > > doesn't support margin and padding goes inside the button.
>
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> > Android Training in London:http://bit.ly/smand1,http://bit.ly/smand2

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate