Just playing around with it, amusingly, it looks like most of what is needed for a button is right in the View superclass anyway. E.g. you can set android:background="@android:drawable/btn_default" on a LinearLayout, call setOnClickListener on it which also makes it clickable, then it properly changes color when you touch it and everything.
On Sep 3, 11:37 am, Zsolt Vasvari <[email protected]> wrote: > Ok, thanks to the both of you. > > On Sep 3, 10:40 am, Mark Murphy <[email protected]> wrote: > > > On Fri, Sep 3, 2010 at 10:32 AM, Lance Nanek <[email protected]> wrote: > > > I've seen it done for fixed size buttons entirely in XML just by using > > > FrameLayout, which overlaps all its children. Inside the FrameLayout > > > you put the button and another layout with the content, then tweak the > > > sizes/padding/margins such that the content looks like it is in the > > > button when really it is above the button. The content isn't > > > clickable, so touching it touches the button behind it. If I had to do > > > a content sized one and couldn't figure out how to do it entirely in > > > XML, I'd probably still steal the same approach, I'd just set the size > > > of the button via code after the layout is sized to the content. That > > > doesn't require any code merging, just managing the size of a button > > > child in a custom layout subclass. > > > You should be able to accomplish the same trick with a RelativeLayout, > > which may be easier to manage, since you can position the pieces > > relative to each other, rather than having to calculate absolute > > coordinates for margins with FrameLayout. > > > -- > > Mark Murphy (a Commons > > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy > > > _The Busy Coder's Guide to Android Development_ Version 3.1 Available! -- 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

