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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:02:50+00:00 2026-06-05T12:02:50+00:00

I am working in an android application and I want to place an ImageView

  • 0

enter image description here

I am working in an android application and I want to place an ImageView in a particular position in my view. For that I applied the particular code and worked successfully :

ImageView image = (ImageView) findViewById(R.id.imageView1);
Bitmap bMap = BitmapFactory.decodeResource(getResources(), R.drawable.mrng);
Matrix mat = new Matrix();
mat.postRotate(350);
Bitmap bMapRotate = Bitmap.createBitmap(bMap, 0, 0, bMap.getWidth(),bMap.getHeight(), mat, true);
image.setImageBitmap(bMapRotate);

Now I want to set a border to this image. For that I made a an shape xml and I have set as the background of the image view.

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#FFFFFF" />
    <stroke android:width="3dp" android:color="#000000" />
</shape>

But when I gave the background of the image view the shape it does not give the correct output.please help me.

I do not want a border around the ImageView, but rather border around the rotated image.

  • 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-05T12:02:51+00:00Added an answer on June 5, 2026 at 12:02 pm

    EDIT: I’m completely rewriting my answer based on the clarification of the question. Here’s how I achieved what you want. The idea is to draw the frame and then rotate:

        ImageView image = (ImageView) findViewById(R.id.TestImage);
        Bitmap bMap = BitmapFactory.decodeResource(getResources(), R.drawable.image);
    
        final int BORDER_WIDTH = 3;
        final int BORDER_COLOR = Color.BLACK;
        Bitmap res = Bitmap.createBitmap(bMap.getWidth() + 2 * BORDER_WIDTH,
                                         bMap.getHeight() + 2 * BORDER_WIDTH,
                                         bMap.getConfig());
        Canvas c = new Canvas(res);
        Paint p = new Paint();
        p.setColor(BORDER_COLOR);
        c.drawRect(0, 0, res.getWidth(), res.getHeight(), p);
        p = new Paint(Paint.FILTER_BITMAP_FLAG);
        c.drawBitmap(bMap, BORDER_WIDTH, BORDER_WIDTH, p);
    
        Matrix mat = new Matrix();
        mat.postRotate(350);
        Bitmap bMapRotate = Bitmap.createBitmap(res, 0, 0, res.getWidth(), res.getHeight(), mat, true);
        image.setImageBitmap(bMapRotate);        
    

    And here’s the screenshot of the result:

    enter image description here

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

Sidebar

Related Questions

I am working android application that required login, Now I want After successfully login
I'm working on an Android application that requires 2D graphical view with a large
I am working on the android application that required login. I want to check
I'm working on a android application that adds every view programmaticaly. When the user
I am working in an android application and I want to work fetch details
I am working in an android application and I want to implement a Gallery.
I have an android application and web-server working together. Now I want user log
I am working on an Android application that needs to determine the current tee
I am working on an Android application that shows a map with the user's
I am working on an Android application in which I want to integrate foursquare

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.