[android-developers] Custom ViewGroup
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+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