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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:33:17+00:00 2026-06-10T21:33:17+00:00

Let’s say we have an Android application which wants to totally manage the display

  • 0

Let’s say we have an Android application which wants to totally manage the display area, so it can adjust sizes of its subcontrols (at runtime, no XML – we need to actively modify subcontrol sizes on the fly).

This application will run in landscape orientation only and no keyboard input so we don’t expect the usable area to ever change.

The sizes of what we will display will be calculated based on this usable area. For example, one item is to take up exactly the left half of the usable area, the right half will be divide amongst other items in strict ratios. Even font sizes will be adjusted so that they fit correctly into the items.

My initial thought was to provide main.xml with nothing but a grid layout with no content but configured to expand to the maximum size (with fill_parent or something similar). We’ll be using the grid layout to position things, but the control we exert over sizes will dictate how the layout manager displays things.

Hopefully, we could then query the grid layout at the appropriate time (after init, before draw) to get the resolution and then adjust all future draws based on that.

Is there a better way to do this? I realise the XML is meant to separate content from presentation but this particular client wants total control over layout and will limit, if necessary, the devices on which the code can run (it’s an in-house app so they can dictate that).

One other thought I had was to add all the subcontrols in the XML with bogus sizes (everything will always be there, it’s just the sizes that may change). However, by doing that, I’m not sure if I’ll lose the ability to get the usable area and hence intelligently adjust the sizes.

  • 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-10T21:33:18+00:00Added an answer on June 10, 2026 at 9:33 pm

    Are you mixing up between resolution and density. What is “usable display resolution” ?. Each device has only one resolution in pixels:

    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    
    final int height = dm.heightPixels;
    final int width = dm.widthPixels;
    

    But what you display depends on your resolution ratio affected by density and display size.

    (UPDATED)

    (1) to see start in Full screen mode and hide all title bar or notification bar:

        // Remove title bar
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        // Remove notification bar
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    

    (2) To get view Rect:

        Rect rect = new Rect();
        Window window = getWindow();
        window.getDecorView().getWindowVisibleDisplayFrame(rect);
        int statusBarHeight = rect.top;
        int contentViewTop = window.findViewById(Window.ID_ANDROID_CONTENT).getTop();
        int titleBarHeight = contentViewTop - statusBarHeight;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a dataset, which can be neatly classified using weka's J48
Let's say I have a method in java, which looks up a user in
Let me explain best with an example. Say you have node class that can
Let's say I have a table with a Color column. Color can have various
Let's say I have an facebook application running using the JS SDK. First user
Let's say I'm building a data access layer for an application. Typically I have
Let's say you have a class called Customer, which contains the following fields: UserName
Let's say I have 2 windows in my application, and two classes responsible for
Let's say I'm writing a Windows Forms (.NET Framework 3.5) application which shows the
Let's say I have two assemblies: BusinessLogic and Web. BusinessLogic has an application setting

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.