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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:22:34+00:00 2026-05-24T02:22:34+00:00

Actually i have created an array of buttons,now my question is whether it will

  • 0

Actually i have created an array of buttons,now my question is whether it will be fit in all screen resolution or not..as i have use nexus s device and the here its working fine..i mean to say that all the buttons are arranged in perfect order..more ever when i placed background image to each buttons its work fine..now i doubt whether it works for cheaper device by the same code i have written or i have to do something extra for that.thats means whether it fit for all screen resolution..or not..the code i have written is..

            LinearLayout layoutVertical = (LinearLayout) findViewById(R.id.liVLayout);
            LinearLayout rowLayout=null;

            LayoutParams param = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT,1);

            //Create Button
            for (i = 0; i<6; i++){
                rowLayout = new LinearLayout(this);
                rowLayout.setWeightSum(7);
                layoutVertical.addView(rowLayout,param);

                for(j=0;j<7;j++){
                    pBtnDay[i][j]=new Button(this);

                    rowLayout.addView(pBtnDay[i][j],param); 

                    pBtnDay[i][j].setOnLongClickListener(this);                         
                    pBtnDay[i][j].setOnClickListener(this);



                }
            }
            return true;

one more thing when i try to find width and height of the buttons it return 0..why?

  • 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-24T02:22:35+00:00Added an answer on May 24, 2026 at 2:22 am

    Using weightSum is the best solution if you know exactly how many elements you want displayed on your screen, across multiple devices. So if it shows up on, say a HTC Wildfire(LDPI) then it will also show on your Nexus(HDPI).

    As for your second question, I´m assuming you are using View.getHeight() and View.getWidth() to obtain these values. Since your buttons hasn´t actually been drawn yet, Android has not designated dimension values to them, that´s why they turn up 0. If you need the width and height of these buttons in onCreate, then you need to do some math of your own 🙂

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

Sidebar

Related Questions

I actually have an answer to my question but it is not parallelized so
I have an onclick handler for an <a> element (actually, it's a jQuery-created handler,
I actually have right now two questions: 1) What font faces are preferred for
I have heard that it's best not to actually have any html in your
I started to use Borland's Turbo C++ a few days ago. I actually have
i have two arrays (actually one, but i created two for each columns). I
I have an array of type string which I want to re-use inside a
I have created an array of pointers. I have used some of them as
I actually have two questions regarding the same problem but I think it is
I actually have two questions regarding exception/error handling in the iPhone app that I

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.