I am trying to create a custom ViewGroup and I want to use it with a fullscreen application. I use "requestWindowFeature (Window.FEATURE_NO_TITLE)" to hide the title bar. The title bar is not displayed, but still takes up space on top of the window.

The image above was created using the following code:
public class CustomLayoutTestActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); Button b = new Button(this); b.setText("Hello"); CustomLayout layout = new CustomLayout(this); layout.addView(b); setContentView(layout); } } public class CustomLayout extends ViewGroup { public CustomLayout(Context context) { super(context); } public CustomLayout(Context context, AttributeSet attrs) { super(context, attrs); } public CustomLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { Log.i("CustomLayout", "changed="+changed+" l="+l+" t="+t+" r="+r+" b="+b); final int childCount = getChildCount(); for (int i = 0; i < childCount; ++i) { final View v = getChildAt(i); v.layout(l, t, r, b); } } }
(The full Eclipse project is here )
It is interesting to see what exactly Android is provided for this custom layout. I configure CustomLayout as the root layout of my activity. OnLayout magazine gets "t = 25", and this is what repels my layout. What I don't know is what I'm doing wrong, which does Android "t = 25" (this is exactly the height of the title bar).
I run this code in Android SDK 2.1, but I also meet in Android 2.2.
EDIT . If I change the CustomLayout class for some default layout (e.g. LinearLayout), the space will disappear. Of course, the default layouts of the Android SDK do not create the layout that I am trying to create, so I create it.
Although the layout I am creating is somewhat complex, it is the smallest code I could create in order to reproduce the problem that I have with my layout.