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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:03:01+00:00 2026-05-22T02:03:01+00:00

Look at the picture below. I’m loading an image from sdcard with code belove.

  • 0

Look at the picture below.
I’m loading an image from sdcard with code belove.

I cannot get the picture to automatically fill the ImageView. I set the background to color green only to highlight the problem. I have tried many android:ScaleType like CENTER and FIT_XY but.

Im now using inSampleSize = 8 but how can the ImageView automatically scale the image to be in the right hight/width proportions and fill the screen

Also another thing, You see the ExitText and Button is placed above the Imageview(I think).
I want them to be under and not block the ImageView. Maybe i misunderstand the android layout technical.

enter image description here

DrawView.java

public class DrawView extends ImageView {

private Context ctx;
public DrawView(Context context, AttributeSet atts) {
    super(context, atts);
    this.ctx = context;
} 
@Override 
protected void onDraw(Canvas canvas) {
    String filePath = Environment.getExternalStorageDirectory().toString() + "/PTPPservice/163693fe-7c48-4568-a082-00047123b9f1.2.IMAG2200.jpg";
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inSampleSize = 8;

    Bitmap bitmap = BitmapFactory.decodeFile(filePath,options);     

    Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
    canvas.drawBitmap(bitmap, null, rect,null);
}

}

Main1.xml

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

<com.hasse.move.DrawView 
    android:id="@+id/mainView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentTop="true"
    android:background="#00FF00"
    android:adjustViewBounds="true"
  />
   <RelativeLayout 
    android:id="@+id/InnerRelativeLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true" >
   <EditText 
    android:id="@+id/edittextaddtext"
    android:layout_width="fill_parent"
    android:layout_toLeftOf="@+id/btnsave"
    android:layout_height="wrap_content"
    android:text="wrap"
   />
   <Button 
    android:id="@+id/btnsave" 
    android:layout_alignParentRight="true" 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="save"
   />
   </RelativeLayout>
 </RelativeLayout>

Main Activity

public class Main extends Activity {

    DrawView theImage;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        // draw the view
        setContentView(R.layout.main1);

        theImage = (DrawView) findViewById(R.id.mainView);
        //do stuff
    }
    @Override
    public void onConfigurationChanged(Configuration newConfig)
    {
    //  Toast.makeText(this, "onConfigurationChanged",Toast.LENGTH_LONG).show();
        super.onConfigurationChanged(newConfig);
    }
}
  • 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-22T02:03:02+00:00Added an answer on May 22, 2026 at 2:03 am

    Here you are using the destination rectangle to be the size of the loaded bitmap instead of the full size of canvas: Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());

    You need to find out the size of your canvas. For that you can use onSizeChanged:

    @Override
    public void onSizeChanged (int w, int h, int oldw, int oldh){
      super.onSizeChanged(w, h, oldw, oldh);
    
      screenW = w;
      screenH = h;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please take a look at the picture below. When we create an object in
please help me with the website heading here. Please look at my picture below:
Look at this image: alt text http://img139.imageshack.us/img139/4488/picture2ep3.png I know how to add UITableView with
I look around and see some great snippets of code for defining rules, validation,
The below code seems like it should work; however, the blob in the database
Hopefully a picture is worth a thousand lines of code because I don't want
Look at this situation: www.websitea.com displays an img tag with a src attribute of
Delegates look like such a powerful language feature, but I've yet to find an
Is it possible to look back through the history of a Subversion repository for
Some things look strange to me: What is the distinction between 0.0.0.0, 127.0.0.1, and

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.