Never mind, pilot error. The .layout method takes l, t, r, b, not width and height. Duh!
Thanks. On May 18, 10:11 pm, John Gaby <jg...@gabysoft.com> wrote: > I am new to Android, and I am trying to understand how to create a > custom ViewGroup. I created MyViewGroup as follows: > > public class MyViewGroup extends ViewGroup { > > public MyViewGroup(Context context) { > super(context); > // TODO Auto-generated constructor stub > } > > @Override > protected void onLayout(boolean changed, int l, int t, int r, int b) > { > } > > } > > Then in my main class I do the following: > > public class HelloAndroid extends Activity { > /** Called when the activity is first created. */ > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > TextView tv = new TextView(this); > MyViewGroup vg = new MyViewGroup(this); > tv.setText("Some Text"); > tv.layout(0, 30, 200, 40); > vg.addView(tv); > setContentView(vg); > } > > } > > Now when I run this, my text "Some Text" is shown, but the bottom is > cut off. It is like the view group in which it is placed is not > filling the entire screen. Is this what is happening? If so, how do > I control the sizeof of my MyViewGroup view? > > Thanks. > > -- > 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+unsubscr...@googlegroups.com > For more options, visit this group > athttp://groups.google.com/group/android-developers?hl=en -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en