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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:35:01+00:00 2026-05-28T06:35:01+00:00

Hey Everyone, import android.widget.Button; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.webpage); but_action =

  • 0

Hey Everyone,

import android.widget.Button;

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.webpage);

        but_action = new Button(getApplicationContext());
        but_action.setVisibility(Button.INVISIBLE);
        toolbar.addView(but_action);

Regarding the code above, this creates an invisible button that i make visible based on some conditions. This works, and so does the logic on the button.

Problem is that the height of the button is static, and this cant be the case. I need this button to simply match its parents height (as you can see its in the toolbar view, which is just a horizontal linearlayout), as the height of the toolbar is different on the tablet sized views as opposed to the phone sized views.

I heard that I need to use LayoutParams, but I will be totally honest: nothing i try validates, and when it does: does nothing. And using setHeight seems to only accept numerical values.

I’m sort of at a roadblock where I’m not sure what else to try.

(also is there something like a float: right; for real-time layout?)

  • 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-28T06:35:02+00:00Added an answer on May 28, 2026 at 6:35 am

    This should do it for you:

    LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);
    but_action.setLayoutParams(lp);
    

    note that when you go to import LayoutParams you want to pick the one that matches your parent, so in this case you’ll import the LinearLayout.LayoutParams

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

Sidebar

Related Questions

Hey everyone, I'm working on a widget for Apple's Dashboard and I've run into
Hey everyone. I'm kinda new to android programming so please bear with me. I'm
Hey everyone! Im pretty new to Android and I have a webView under 2
Hey everyone. I'm trying to make a swing GUI with a button and a
Hey everyone, I'm currently deciding how to layout a store front. I'm very fond
Hey everyone I am having a little problem with my jQuery I am trying
Hey everyone, I'm back and looking forward to more of your brilliance. I have
Hey everyone. The following is the code that I am using to play random
Hey everyone, great community you got here. I'm an Electrical Engineer doing some programming
Hey everyone, here is the site in question: http://www.myvintagesecret.com/ I have a bunch of

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.