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

  • SEARCH
  • Home
  • 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 8192277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:08:25+00:00 2026-06-07T04:08:25+00:00

In my android app I need a layout as shown below A relative layout

  • 0

In my android app I need a layout as shown below

enter image description here

A relative layout is used as the parent layout inside I use 4 relative layout to arrange the contents- header layout 1,header layout 2, content layout(objRLScrollView -scroll view is inside this layout) and a footer layout

I use the below code to create the above layout

    public class Login1 extends Activity {




     @Override
        public void onCreate(Bundle savedInstanceState) {

          super.onCreate(savedInstanceState);

           this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
           this.requestWindowFeature(Window.FEATURE_NO_TITLE);

            RelativeLayout objRLBody=new RelativeLayout(this);
            objRLBody.setId(1001);
            RelativeLayout.LayoutParams objLLBodyParams=new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
            objRLBody.setBackgroundColor(Color.parseColor("#d8e4f3"));
            objRLBody.setLayoutParams(objLLBodyParams); 


            /* header portion starts here*/

            RelativeLayout objRLActionBar=new RelativeLayout(this);
            objRLActionBar.setId(1002);
            RelativeLayout.LayoutParams objRLActionBarParams=new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,50);
            objRLActionBarParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); 
            objRLActionBar.setLayoutParams(objRLActionBarParams);
            objRLActionBar.setBackgroundColor(Color.parseColor("#2e4862"));



            objRLBody.addView(objRLActionBar);


            RelativeLayout objRLSelectedActionBar=new RelativeLayout(this);
            objRLSelectedActionBar.setId(1003);
            RelativeLayout.LayoutParams objRLSelectedActionBarParams=new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
            objRLSelectedActionBarParams.addRule(RelativeLayout.BELOW,objRLActionBar.getId()); 
            objRLSelectedActionBar.setLayoutParams(objRLSelectedActionBarParams);
            objRLSelectedActionBar.setBackgroundColor(Color.WHITE);
            objRLSelectedActionBar.setGravity(Gravity.CENTER|Gravity.LEFT);


            TextView objTVSelectedAction = new TextView(this); 
            RelativeLayout.LayoutParams objTVSelectedActionParams=new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
            objTVSelectedAction.setLayoutParams(objTVSelectedActionParams);
            objTVSelectedAction.setGravity(Gravity.CENTER);
            objTVSelectedAction.setTextColor(Color.BLACK);
            objTVSelectedAction.setTextSize(TypedValue.COMPLEX_UNIT_DIP,18);
            objTVSelectedAction.setText("Scroll Test"); 
            objTVSelectedAction.setTypeface(null, Typeface.BOLD);
            objTVSelectedAction.setPadding(4, 0, 4, 0);
            objTVSelectedAction.setId(1004);
            objRLSelectedActionBar.addView(objTVSelectedAction);  


            objRLBody.addView(objRLSelectedActionBar);

            /* header portion ends here*/



            /* Relative layout which hold scroll view*/
            RelativeLayout objRLScrollView = new RelativeLayout(this); 
            objRLScrollView.setId(1005);
            objRLScrollView.setBackgroundColor(Color.parseColor("#d8e4f3"));
            objRLScrollView.setGravity(Gravity.CENTER_VERTICAL|Gravity.CENTER_HORIZONTAL);
            RelativeLayout.LayoutParams objRLScrollViewParams = new RelativeLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); 
            objRLScrollViewParams.addRule(RelativeLayout.BELOW ,objTVSelectedAction.getId());


            ScrollView  objScrollView=new ScrollView(this);
            objScrollView.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
            objScrollView.setFillViewport(true);



            /* contents */

            RelativeLayout objRLContent = new RelativeLayout(this); 
            objRLContent.setId(1006);
            objRLContent.setBackgroundColor(Color.parseColor("#d8e4f3"));
            objRLContent.setGravity(Gravity.CENTER_VERTICAL|Gravity.CENTER_HORIZONTAL);
            RelativeLayout.LayoutParams objRLContentParams = new RelativeLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); 
           // objRLContentParams.addRule(RelativeLayout.BELOW ,objTVSelectedAction.getId()); 
            objRLContent.setLayoutParams(objRLContentParams);                


                  /* adding layouts containing Edittext (for testing scroll view) */

                RelativeLayout rl2= addEditText(objRLContent,null,1);
                RelativeLayout rl3= addEditText(objRLContent,rl2,2);
                RelativeLayout rl4= addEditText(objRLContent,rl3,3);
                RelativeLayout rl5= addEditText(objRLContent,rl4,4);
                RelativeLayout rl6= addEditText(objRLContent,rl5,5);
                RelativeLayout rl7= addEditText(objRLContent,rl6,6);
                RelativeLayout rl8= addEditText(objRLContent,rl7,7);
                RelativeLayout rl9= addEditText(objRLContent,rl8,8);
                RelativeLayout rl10= addEditText(objRLContent,rl9,9);
                RelativeLayout rl11= addEditText(objRLContent,rl10,10);
                RelativeLayout rl12= addEditText(objRLContent,rl11,11);
                RelativeLayout rl13= addEditText(objRLContent,rl12,12);






             objScrollView.addView(objRLContent);  // adding contents to scroll view


             objRLScrollView.addView(objScrollView);  // Adding scroll view to a relative layout


             objRLBody.addView(objRLScrollView);  // adding relative layout to body layout



             // adding footer to body

               RelativeLayout objRLFooter=new RelativeLayout(this);
               RelativeLayout.LayoutParams objRLFooterParams=new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,25);
               objRLFooterParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,objRLBody.getId()); 
               objRLFooter.setLayoutParams(objRLFooterParams);
               objRLFooter.setBackgroundColor(Color.parseColor("#2e4862"));
               objRLFooter.setGravity(Gravity.CENTER);
               objRLBody.addView(objRLFooter); 




               this.setContentView(objRLBody); 






      }




     private RelativeLayout addEditText(RelativeLayout objRLContent,RelativeLayout layoutAbove,int i   ) {



            RelativeLayout objRLEditText = new RelativeLayout(this); 
            objRLEditText.setId(1100+i);
            RelativeLayout.LayoutParams objRLEditTextParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            if(layoutAbove!=null)
            objRLEditTextParams.addRule(RelativeLayout.BELOW,layoutAbove.getId());
            objRLEditText.setLayoutParams(objRLEditTextParams);
            objRLEditText.setPadding(8, 2, 8, 2);

             EditText objETData = new EditText(this);
             objETData.setId(1300+i);
             RelativeLayout.LayoutParams objETDataParams=new RelativeLayout.LayoutParams(200,LayoutParams.WRAP_CONTENT);
             objETData.setLayoutParams(objETDataParams);
             objETData.setPadding(8, 0, 8, 0);
             objETData.setTextSize(TypedValue.COMPLEX_UNIT_DIP,18);
             objETData.setText(""+i);
             objETData.setSingleLine(true);
             objRLEditText.addView(objETData);           

             objRLContent.addView(objRLEditText);

             return objRLEditText;



     }


}

and the above code gives out put as shown below

enter image description here

The header layouts becomes invisible due to the presence of scrollView. What is wrong with my code? what should i do to get a layout with scrollable contents with fixed header and footer? plz help.

  • 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-06-07T04:08:26+00:00Added an answer on June 7, 2026 at 4:08 am

    1- Set your ScrollView’s height and width to match_parent.

    2- Set your Scrollview’s Top and Bottom padding equal to your top and bottom bar height.

    3- Set your top bar’s alignment to alignparenttop

    4- Set your bottom bar’s alignment to alignparentbottom

    Note: If you want a good compatibility library for action bars consider using ActionBarSherlock.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am making android UI (using Relative Layout)in which, i need to set one
My android app project need to add a new function of saving the click
Android Calendar App I need to be able to implement a view similar to
To create facebook android native app we need to provide our Android application signature
I'm writing an android app and I need to read several files from several
I'm building an Android app and I need to have two different themes for
I'm working on an Android app and I need to to post to a
I'm working with an existing Android app and I need to have a dynamically
I need to test my Android app for playing flash objects in the WebView.
I need to develop an android app that achieves the following: Create an activity

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.