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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:05:54+00:00 2026-06-10T20:05:54+00:00

my current android project requires the width of button should be set dynamically depending

  • 0

my current android project requires the width of button should be set dynamically depending on the resolution available on device

i want to arrange 9 button in a row but the size will depend on the resolution available

for the current scene we are using below code

    DisplayMetrics displaymetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    //int sheight = displaymetrics.heightPixels;
    int swidth = displaymetrics.widthPixels;
    int px=swidth/11;
    bW.setWidth(px);
    bE.setWidth(px);
    bR.setWidth(px);
    bT.setWidth(px);
    bY.setWidth(px);
    bU.setWidth(px);
    bI.setWidth(px);
    bO.setWidth(px);
    bP.setWidth(px);

somehow the width of button is not changed in any manner it remains the same

  • 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-10T20:05:55+00:00Added an answer on June 10, 2026 at 8:05 pm

    i came up with this solution

        ViewGroup.LayoutParams params = button.getLayoutParams();
        params.width=px;
        button.setLayoutParams(params);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display the current revision number of my Android project to the
I imported my current Android Project to Eclipse on my (Mac OS) device via
We want to integrate EGIT plugin to our current eclipse android project. But could
On a current Android project, I pass some data between a couple activities. I
m.google.com somehow requests the current location when loaded in Android's browser. I want to
I'm working on android unity3d project where I want to post some stuff to
In my project build definition the SettingKey useProguard in the Android scope is set
I'm current calling the link in my Android project. How can I traverse the
I have a project that compiles, loads and runs in the android device nicely.
I'm trying to import and existing Android project into my current Eclipse workspace. 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.