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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:46:43+00:00 2026-05-20T17:46:43+00:00

My app needs the height and width of the extended ImageView. I thought this

  • 0

My app needs the height and width of the extended ImageView. I thought this should work:

package my.android.test;

public class TestImageView extends ImageView
{
    private int mWidth=0;
    private int mHeight=0;

    public TestImageView(Context context, AttributeSet as)
    {
        super(context, as);
        final String xmlns="http://schemas.android.com/apk/res/android";
        mWidth = as.getAttributeIntValue(xmlns, "layout_width", 0);
        mHeight = as.getAttributeIntValue(xmlns, "layout_height", 0);
    }

    @Override
    protected void onDraw(Canvas canvas)
    {
        //do stuff
    }
}

but it doesn’t work. 0 is returned by getAttributeIntValue() eventhough the layout_height is defined in the layout XML:

<?xml version="1.0" encoding="utf-8"?>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="vertical"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:fillViewport="true"
          android:background="#fffcb95a"

<LinearLayout android:orientation="vertical"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"

<FrameLayout android:layout_width="fill_parent"
             android:layout_height="wrap_content"

    <RelativeLayout android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:padding="6dip"

        <my.android.test.TestImageView
                    android:id="@+id/TestImageViewID" 
                    android:layout_width="100dip"
                    android:layout_height="100dip"
                    android:src="@drawable/icon"
                    android:scaleType="centerCrop" />

    </RelativeLayout

</FrameLayout

</LinearLayout
</ScrollView

what to do ?

  • 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-20T17:46:44+00:00Added an answer on May 20, 2026 at 5:46 pm

    Just call getWidth() and getHeight().

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

Sidebar

Related Questions

I need to change the mainwindow or the native app size width x height
We need to create a full page HTML/Javascript app (100% HEIGHT/WIDTH) that does not
My app needs to have variable height table cells (as in each table cell
My app needs to build a buffer from all the selected cells on a
My app needs to play some audio files and I want to fade-out the
My app needs to be set in iOS 5 Notification Center as 'alerts' and
My app needs many NSStrings containing differente hard coded web URLs, to be accessed
My app needs to display a graphical representation of a value ranging from -1
My current app needs to store address information for a user. I'm currently debating
My Cocoa app needs some small dynamically generated windows. How can I programmatically create

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.