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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:31:01+00:00 2026-06-14T16:31:01+00:00

I am developing a custom ViewGroup that contains a number of views. In the

  • 0

I am developing a custom ViewGroup that contains a number of views. In the constructor, I create a number of FrameLayouts that will each contain two ImageViews. Each Framelayout and the child views are created using the following code.

FrameLayout frame = new FrameLayout(context);

ImageView digitView = new ImageView(context);
digitView.setScaleType(ScaleType.CENTER_CROP);
frame.addView(digitView,
        new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));

ImageView bezelView = new ImageView(context);
bezelView.setScaleType(ScaleType.CENTER_CROP);
bezelView.setImageResource(R.drawable.bezel);
frame.addView(bezelView);


this.addView(frame, params); 

In the onMeasure callback I set the dimensions of the custom ViewGroup

        this.setMeasuredDimension(254, 43);

and in the onLayout callback, I calculate the dimensions of each of the FrameLayouts and call the layout method for each

@Override
protected void onLayout (boolean changed, int left, int top, int right, int bottom)
{
    if (changed)
    {
        float width = (float)(right - left) / (float)this.digits;

        if ((int)(width/ASPECT_RATIO) > bottom- top)
            width = (float)(bottom - top) * ASPECT_RATIO;
        this.digitWidth = (int)width;
        this.digitHeight = (int)(width/ASPECT_RATIO);

        this.xOffset = ((right - left) - (this.digits * this.digitWidth))/2;
        this.yOffset = ((bottom - top) - this.digitHeight)/2;

        for (int i = this.digits-1; i >=0; i--)
        {
            int x = xOffset + i * this.digitWidth;
            this.placeFrames.get(i).layout(x, this.yOffset, x + this.digitWidth, yOffset + this.digitHeight); 

        }
    }
}

The issue I am having is that the FrameLayouts are being correctly sized and positioned within the custom GroupView, but the ImageViews are not being resized by the FrameLayouts – they have zero width and height. I validated this using the HierarchyViewer.

I think I’ve missed something – I assumed that the layout method on the FrameLayout would take care of resizing the child ImageViews based on the layout parameters passed in when they were added to the FrameLayout as children, but it seems not.

A pointer in the right direction would be very much appreciated.

Thanks

Andrew

  • 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-14T16:31:03+00:00Added an answer on June 14, 2026 at 4:31 pm

    I assumed that the layout method on the FrameLayout would take care of resizing the child ImageViews based on the layout parameters passed in when they were added to the FrameLayout as children, but it seems not.

    You are not layout() these ImageView objects yourself nor calling super.onLayout()..

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

Sidebar

Related Questions

We are developing a custom textual DSL, that will ultimately get integrated into Visual
As part of the team developing a custom application framework that will be given
I am developing a custom shopping cart for which existing customers will need to
Does anyone have any good links for developing custom field and content types that
I'm developing custom client/server application that requires client to log in with their username
I am developing custom iPad applications for clients. So far I know that you
Say you're developing a custom control and there's a key template part that your
I'm developing a custom control that doesn't inherit from Button. I want to implement
I'm developing custom listener for JMeter. The problem is that listener works fine on
I'm currently developing a custom control and realize that my code is being run

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.