Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6668477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:02:45+00:00 2026-05-26T03:02:45+00:00

I have a linearlayout, which the first element is a imageview header, and the

  • 0

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:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:02:46+00:00Added an answer on May 26, 2026 at 3:02 am

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

    public class MainGrid extends Activity {
        private GridView myGridView;
        private ImageAdapter myImageAdapter;
        private ImageView header;
    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LinearLayout ll = new LinearLayout(this);
        ll.setOrientation(LinearLayout.VERTICAL);
        ll.setGravity(Gravity.TOP);   // SET THIS TO TOP
    
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
        ll.setLayoutParams(lp);
        // I'VE ADDED LAYOUTPARAMS TOO
    
        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);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a parent LinearLayout in which has some ImageView s, now I set
I have a ViewGroup (LinearLayout) which contains a couple of TextViews and one ImageView.
I have a gridview in which there are two elements in each of its
I have a LinearLayout which has a background image (a 9 patched png file).
I'm trying to set my root LinearLayout element (which is set to fill_parent in
I have a project using a ViewPager which works correctly: I can page from
I have add a ViewFlipper in which has 2 linearlayout,and I have made an
I have ScrollView which contains 10 buttons. When a activity is launched only first
Which class do I have to use, when setting the LayoutParams of my LinearLayout
I have a horizontal LinearLayout, inside which I have 2 TextViews. Let's say that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.