java - Android custom view layout issues -
short , sweet summary:
when changing class view
-derived viewgroup
-derived, height and/or width params passed onsizechanged
not consistent class when used inside of linearlayout. there additional information need supply when using viewgroup super class achieve consistent results?
long version:
i have created custom view-derived visual control i'm using custom button. derive view , add layouts this:
class declaration:
public class gamebutton extends view {
xml:
<linearlayout android:layout_width="fill_parent" android:layout_height="0dip" android:orientation="horizontal" android:layout_weight="1"> <com.myname.myapp.controls.gamebutton android:id="@+id/button1" android:layout_width="0dip" android:layout_height="fill_parent" android:layout_weight="1" />
i want little fancier control, have changed derive viewgroup or subclass of viewgroup (currently trying make relativelayout, example). this, disappears.
i added logging see values being passed onsizechanged, , i'm getting 0 height being passed onsizechanged every instance of control no change layout xml (above) works otherwise when derive directly view.
do need add additional hints, params or layout parameters either xml or in code when switching view viewgroup?
you need implement onmeasure() tell toolkit size (you must call setmeasureddimension() @ end of onmeasure().) viewgroup, default, compute size based on children , don't have here, size 0x0.
Comments
Post a Comment