Android Developer has a nice discussion on writing your own View subclasses: http://developer.android.com/guide/topics/ui/custom-components.html
But I want to write my own ViewGroup subclass with my own child positioning policy. Where is there a minimal example of this kind of thing? (This is a Java coding question not an XML one)
Specifically I want a horizontal layout that (like LinearLayout) fills in children from the left - but once the horizontal space is consumed, shifts the children to the left so that the last child appears aligned to the right end of the layout. The children are button-like and so a HorzontalScrollView does not work since the scrolling gesture clicks the buttons instead of moving them.
If LinearLayout has an option to do this, I could not find it.
HorizontalScrollView
should work, scrolling should not click the buttons. But if you really want to write your own custom layout, have a look at this archive (the video is also available)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With