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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:37:11+00:00 2026-05-31T14:37:11+00:00

I defined two ImageViews and set the background like this: int tmpID = findViewById(R.id.mypng)

  • 0

I defined two ImageViews and set the background like this:

  int tmpID = findViewById(R.id.mypng)
  ImageView   tmpIV.setBackgroundResource(tmpID);

And this is the xml with the Image views:

<RelativeLayout
        android:id="@+id/myDisplay"
        android:layout_width="wrap_content"
        android:layout_height="100dp"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="0dp" >

        <ImageView
            android:id="@+id/b1"
            android:layout_width="300dp"
            android:layout_height="match_parent"
            android:contentDescription="@string/anyStringValue"
            android:scaleType="fitCenter" />

        <ImageView
            android:id="@+id/b2"
            android:layout_width="300dp"
            android:layout_height="match_parent"
            android:layout_toRightOf="@+id/b1"
            android:contentDescription="@string/anyStringValue"
            android:scaleType="fitCenter" />

Now all that should happen is that when I set the background of the imageviews, the png adjusts uniformly its size to the parents 100dp height while the width should scale uniformly – down or up.

I tried to set the width smaller and larger. When its set to 300dp for example then it stretches the png width to 300 and 100 height while it should only stretch it’s width so far that the height reaches 100.

I thought “fitCenter” would do that. I also tried all the other attribute values, but without luck.

Thanks!

  • 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-31T14:37:12+00:00Added an answer on May 31, 2026 at 2:37 pm

    android:scaleType only take care about the android:src why don’t you use that param?? do you really want use background and don’t set a source?

    Maybe yoy can have one RelativeLayout with two ImageView for each imageView, one with the “background scaled” and the der with the real source.

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

Sidebar

Related Questions

I have defined two handlers for category with same name in standalone.xml file, like
I defined two CSS classes that set the background to an image (shown below).
I have a User table defined like this: CREATE TABLE Users( UserId int IDENTITY(1,1)
i defined two routes in global.asax like below context.MapRoute(HomeRedirect, , new { controller =
I defined two classes: class Token_ { public: virtual char operator*()const = 0;//this fnc
I have defined two classes in javascript as follows. function ParentClass(){ this.one = function(){
I have Two Image Views Defined in Xml. I want to Change the Position
I defined two functions for array: Array.prototype.remove = function(obj) { var i = this.length;
I have defined two models where each one references the other, like so: class
I have defined two endpoints in my App.Config file as <system.serviceModel> <services> <service name=HostDirectAddress.ITestService

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.