I have a linearlayout, which the first element is a imageview header, and the second element is a gridview.
It works fine, but I have a erroneal black space of 50px (more or less) between the android title bar and the header of the app, which is the first element of the linearlayout
Why do I have that space? The only way I find to remove it is to put this line: ll.setPadding(0, -50, 0, 0);
This is the full code:
public class MainGrid extends Activity {
private GridView myGridView;
private ImageAdapter myImageAdapter;
private ImageView header;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);//turn off the window's title bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//fullscreen
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
ll.setGravity(Gravity.CENTER);
//ll.setPadding(0, -50, 0, 0);
header = new ImageView(getApplicationContext());
header.setImageResource(R.drawable.header_acc);
myGridView = new GridView(this);
myImageAdapter=new ImageAdapter(this);
myGridView.setAdapter(myImageAdapter);
ll.addView(header);
ll.addView(myGridView);
setContentView(ll);
}
The snapshot:

Update: This should work just fine if you set
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"in the Manifest.