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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:25:33+00:00 2026-06-11T19:25:33+00:00

I have an ImageView containing an image. This image is rotated by button clicks,

  • 0

I have an ImageView containing an image. This image is rotated by button clicks, but sometimes it gets smaller or gets its original size. I have no idea what causes this.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >

    //tablelayout here

     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true" 
        android:layout_centerVertical="true"
        android:orientation="vertical" >
    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:maxWidth="200dp" 
        android:maxHeight="200dp"
         /> 
    </LinearLayout>
</RelativeLayout>

Inital settings:

 iv = (ImageView)findViewById(R.id.imageView1);
        int id = getResources().getIdentifier("landolt", "drawable", getPackageName());
        iv.setImageResource(id);

        myImg = BitmapFactory.decodeResource(getResources(), R.drawable.landolt);
        matrix = new Matrix();

        size = 200;

        randomize = new Random();
        random = randomize.nextInt(8) + 1;
        rotate = getAngle(random);  //function created by me
        matrix.postRotate(rotate);
        rotatedBitmap = Bitmap.createBitmap(myImg, 0, 0, myImg.getWidth(), myImg.getHeight(), matrix, true);
        iv.setImageBitmap(rotated);

So the image is rotated, no size change in code.

A rotation on button click:

                btn1.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (rotate == -90)
                        {
                          //rotate back to original direction
                            old_rotate = -rotate;
                            matrix.postRotate(old_rotate);
                          //next rotation
                            random = randomize.nextInt(8) + 1;
                            rotate = getAngle(random);
                            matrix.postRotate(rotate);
                            rotatedBitmap = Bitmap.createBitmap(myImg, 0, 0, myImg.getWidth(), myImg.getHeight(), matrix, true);
                            iv.setLayoutParams(new LinearLayout.LayoutParams(size, size));
                            iv.setImageBitmap(rotated);
                        }
                    }
                    });

When I launch the activity, the image appears with its original size, sometimes smaller. When I click on a button the image gets smaller or gets as big as its original size.

What is going on?

  • 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-11T19:25:34+00:00Added an answer on June 11, 2026 at 7:25 pm

    I figured out why does the image keep changing size. It simply doesn’t have enough place in the imageView when rotated. I found the solution to my problem on this link.

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

Sidebar

Related Questions

I have this SQLite containing a number of 'Projects'. Each 'Project' with its attributes
I have an ImageView containing a Bitmap image. The image is twice as big
I have an Activity containing an ImageView and I'd like to allow the User
I have imageView in activity. How I can set position this imageView in my
I have this ImageView in my layout: <ImageView android:layout_width=fill_parent android:layout_height=wrap_content android:contentDescription=@string/image_divider android:paddingBottom=8dp android:paddingTop=4dp android:scaleType=fitXY
I have an Activity with a layout containing a custom ImageView and a few
I have a layout containing two textViews and one ImageView. the first text is
I have an ImageView that is 1x20px. The image is a .9.png. I am
I have a listview with each item containing an image, a textview and a
I have a table containing images and buttons. Each button has a tag with

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.