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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:00:50+00:00 2026-06-18T06:00:50+00:00

There are several constructors available for defining an ImageView. For Example 1) public ImageView

  • 0

There are several constructors available for defining an ImageView.
For Example

1) public ImageView (Context context)
2) public ImageView (Context context, AttributeSet attrs)
3) public ImageView (Context context, AttributeSet attrs, int defStyle)** 

I am confused in using 2nd and 3rd type of constructor.
basically i don’t know what to pass in place of AttributeSet.
Kindly provide a coding example.

  • 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-18T06:00:51+00:00Added an answer on June 18, 2026 at 6:00 am

    Ways of creating imageView, ImageView with Context

    ImageView image= new ImageView(context);
    

    Here when you want set the values like height, width gravity etc you need to set

    image.set****();
    

    based on the number of attributes you need to use no of setXXX() methods,.

    2.Using Attribute set
    you can define set of attributes like height, width etc in your res/values folder in separate xml file, pass the xml file to getXml()

    XmlPullParser parser = resources.getXml(yourxmlfilewithattribues);
     AttributeSet attributes = Xml.asAttributeSet(parser);
    ImageView image=new ImageView(context,attributes);
    

    Here you can also define your custom attributes in your xml . and you can access the by using the methods provided by AttributeSet class example

    getAttributeFloatValue(int index, float defaultValue)
    

    //Return the float value of attribute at ‘index’

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

Sidebar

Related Questions

Say several of my controllers constructors take an interface - IPetInterface There are 3
I have a class with several data members: public class Foo { List<int> intLst;
I'm using Tkinter for a simple trivia game. There are several buttons, one for
There are several threads on this here at SO but I didn't find one
There are several other questions about this topic that I have gone through, but
There are several variant questions on this on SO, but I did not find
There are several places on the internet that talk about having multy key dictionary
There are several ways google throws at me for checking if a file is
There are several good Javascript editors for Markdown / Textile (e.g.: http://attacklab.net/showdown/ , the
There are several resources out there that explain how the sandbox in Chrome works

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.