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 8078907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:56:28+00:00 2026-06-05T15:56:28+00:00

I have recently coded my button to be aligned to the right of the

  • 0

I have recently coded my button to be aligned to the right of the screen and it seems to not want to work.
I have also checked to see if my parent layout is set to cover the whole width of the screen and it is.

    public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);

    //Vertical Layout - For the layout of the newSheetLayout.
    newSheetLayoutV = new LinearLayout(this);
    newSheetLayoutV.setOrientation(LinearLayout.VERTICAL);

    //Horizontal layout - nested in Vertical layout. Used for the next, back and save buttons.
    newSheetButtonLayoutH = new LinearLayout(this);
    newSheetButtonLayoutH.setOrientation(LinearLayout.HORIZONTAL);

  //Vertical Layout - For the layout of the newSheetLayout.
    dataShowV = new LinearLayout(this);
    dataShowV.setOrientation(LinearLayout.VERTICAL);

    //Horizontal layout - nested in the dataShow V. Used for the data entry objects.
    dataShowH = new LinearLayout(this);
    dataShowH.setOrientation(LinearLayout.HORIZONTAL);

    //Next button.
    nextButton = new Button(this);
    nextButton.setText("NEXT >");
    nextButton.setOnClickListener(nextListener);

    //Back button.
    backButton = new Button(this);
    backButton.setText("< BACK");
    backButton.setOnClickListener(backListener);
    backButton.setEnabled(false);

    //Save button.
    saveButton = new Button(this);
    saveButton.setText("Save");
    saveButton.setOnClickListener(saveListener);
    saveButton.setEnabled(false);

    //Addition of the buttons to the button view in order that needs to be seen.
    newSheetButtonLayoutH.addView(backButton);
    newSheetButtonLayoutH.addView(nextButton);
    newSheetButtonLayoutH.addView(saveButton);

    //Layout Param's for the buttons.
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    newSheetButtonLayoutH.setLayoutParams(params); 

    //Set save to anchor right.
    LinearLayout.LayoutParams saveButtonParam = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    saveButtonParam.gravity = Gravity.RIGHT;
    saveButton.setLayoutParams(saveButtonParam);

    //Add all the layout Views to the main layout view.
    newSheetLayoutV.addView(dataShowV);
    newSheetLayoutV.addView(newSheetButtonLayoutH);
    newSheetLayoutV.setGravity(Gravity.BOTTOM);

    setContentView(newSheetLayoutV);
}

If it is something simple and I’m very blind to the solution, I will punish myself accordingly.

Thank you for your 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-05T15:56:29+00:00Added an answer on June 5, 2026 at 3:56 pm

    try

    saveButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,Gravity.RIGHT);
    

    if you are using xml and your need is not to do it in dynamic way then do

    android:layout_gravity="right"
    

    Edit:
    i think this is what you want

    enter image description here

    LinearLayout newSheetLayoutV,dataShowV,dataShowH,newSheetButtonLayoutH,newlayout;
        Button nextButton,backButton,saveButton;
        //RelativeLayout ;
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            newSheetLayoutV = new LinearLayout(this);
            newSheetLayoutV.setOrientation(LinearLayout.VERTICAL);
    
            //Horizontal layout - nested in Vertical layout. Used for the next, back and save buttons.
            newSheetButtonLayoutH = new LinearLayout(this);
            newSheetButtonLayoutH.setOrientation(LinearLayout.HORIZONTAL);
            newlayout = new LinearLayout(this);
            newlayout.setOrientation(LinearLayout.VERTICAL);
            newlayout.setGravity(Gravity.RIGHT);
            newlayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
            //newSheetButtonLayoutH = new RelativeLayout(this);
    
    
          //Vertical Layout - For the layout of the newSheetLayout.
            dataShowV = new LinearLayout(this);
            dataShowV.setOrientation(LinearLayout.VERTICAL);
    
            //Horizontal layout - nested in the dataShow V. Used for the data entry objects.
            dataShowH = new LinearLayout(this);
            dataShowH.setOrientation(LinearLayout.HORIZONTAL);
    
            //Next button.
            nextButton = new Button(this);
            nextButton.setText("NEXT >");
            //nextButton.setOnClickListener(nextListener);
    
            //Back button.
            backButton = new Button(this);
            backButton.setText("< BACK");
            //backButton.setOnClickListener(backListener);
            backButton.setEnabled(false);
    
            //Save button.
            saveButton = new Button(this);
            saveButton.setText("Save");
            //saveButton.setOnClickListener(saveListener);
            saveButton.setEnabled(false);
            LinearLayout.LayoutParams saveButtonParam = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            //saveButtonParam.gravity = Gravity.RIGHT;
            saveButton.setLayoutParams(saveButtonParam);
            //Addition of the buttons to the button view in order that needs to be seen.
    
            newSheetButtonLayoutH.addView(backButton);
    
            newSheetButtonLayoutH.addView(nextButton);
            newlayout.addView(saveButton);
            newSheetButtonLayoutH.addView(newlayout);
    
            //Layout Param's for the buttons.
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
            newSheetButtonLayoutH.setLayoutParams(params); 
    
            //Set save to anchor right.
    
    
            //Add all the layout Views to the main layout view.
            newSheetLayoutV.addView(dataShowV);
            newSheetLayoutV.addView(newSheetButtonLayoutH);
            newSheetLayoutV.setGravity(Gravity.BOTTOM);
    
            setContentView(newSheetLayoutV);
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have recently created a test paypal account, and also verified all the details,
I recently started to work with the Facebook API and I'm have some problems
I have recently made changes in some code that makes a char name field
We have recently started using FxCop on our code base and I am in
I have recently started using DocCheck for checking the validity of JavaDoc's in code
Bah! I have recently installed the MiniProfiler from http://code.google.com/p/mvc-mini-profiler/ attempting to find all the
I recently have a problem that my java code works perfectly ok on my
Recently I have modified my code to While taking input form STDIN, I moved
Recently I have seen this code in a WebSite, and my question is the
recently I have seen this code arrMove = new List<int[]>(4); m_pppiCaseMoveDiagLine = new int[64][][];

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.