Images that have been resized on Android appear blurry when viewed on the second page

Customizing the Toolbar:

#main_bar {
    background: url(../images/logo.jpg) 99% 50% no-repeat;
    background-size: auto 80%;
}

The original size of logo.jpg is 220x266px

The toolbar has a fixed height of 46px

Therefore, the background image appears to be about 36px in height

It should be noted that the toolbar design remains consistent across all two pages

However, an issue arises as follows: The clarity of the image is perfect upon app initialization but becomes blurry when transitioning to the second page. The blurriness persists even upon returning to the first page.

After attempting to adjust with the following code:

background-size: auto 36px;

The problem still persists despite this change

Any advice or recommendations on how to address this concern would be greatly appreciated

Thank you, Irina

Answer №1

Here is a method that resizes a Bitmap image in Java:


public Bitmap resizeBitmapImage(String filePath, int targetWidth, int targetHeight) {
    Bitmap bitmapImage = null;
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(filePath, options);
    double sampleSize = 0;

    boolean scaleByHeight = Math.abs(options.outHeight - targetHeight) >= Math.abs(options.outWidth - targetWidth);

    if (options.outHeight * options.outWidth * 2 >= 1638) {
        sampleSize = scaleByHeight ? options.outHeight / targetHeight : options.outWidth / targetWidth;
        sampleSize = (int) Math.pow(2d, Math.floor(Math.log(sampleSize) / Math.log(2d)));
    }

    options.inJustDecodeBounds = false;
    options.inTempStorage = new byte[128];
    
    while (true) {
        try {
            options.inSampleSize = (int) sampleSize;
            bitmapImage = BitmapFactory.decodeFile(filePath, options);
            break;
        } catch (Exception ex) {
            try {
                sampleSize = sampleSize * 2;
            } catch (Exception ex1) {
                
            }
        }
    }

    return bitmapImage;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Changing the Input Label Color on Hover in Material-UI TextField

I have a custom styled Mui TextField called CustomTextField. It changes the input background color and font color on hover, but I also want to change the label font color when hovered over. Currently, the input background changes from black to white on hov ...

rectangle/positionOffset/position().top/any type of element returning a position value of 0 within the container

While the height/position of the container is accurately displayed, attempting to retrieve the top position (or any position) of containing elements yields a return value of 0. Additionally, using .getBoundingClientRect() results in all values (top, left, ...

I'm having an issue where my footer is getting cut off when I resize the browser and start side scrolling. Can

I designed a webpage with a footer that contains another div holding centered content. The footer is supposed to span the entire width, while the inner content div is set to 960px with a margin auto to center it. <footer> <div class="footer-in ...

How can I customize the styling of Autocomplete chips in MUI ReactJS?

Trying to customize the color of the MUI Autocomplete component based on specific conditions, but struggling to find a solution. Any ideas? https://i.stack.imgur.com/50Ppk.png ...

Adding space around images in JavaFX

Just a quick question. I'm wondering if there is a way to apply padding to an ImageView using CSS in JavaFX. I've attempted insets, padding, and other methods with no success. Alternatively, can the same effect be achieved with a Text Object? ...

Issue with alert dialog displaying multiple items with colors is not being resolved

Currently, I am using a style to customize my Alert Dialog. Most of the elements are styled as desired, however, the multichoice items are not reflecting the color change. Additionally, I would like the checkboxes to be displayed in white but I am unsure h ...

The behavior of the CSS Position property is exhibiting unique characteristics when used in

I am encountering an issue where an image is displaying differently based on the position attribute in Firefox compared to Chrome and IE11. Take a look at the preview on . Notice how the bottom tip of "Fountain Valley" is incorrectly positioned in Firefox ...

Having Trouble Changing CSS with Rails Link_to CSS ID

While following the ruby on rails guide, I came across a specific way to write link_to's with a css id: <%= link_to "About", about_path, id: "third" %> I also attempted: <%= link_to ("About", :id => "third"), about_path %> Although ...

Troubleshooting the challenges with jQuery's next().addClass() and prev().addClass() functions

I am attempting to create a slider feature. I have four different contents that I've positioned consecutively, but made them invisible initially. I defined a class called active-client with the attribute display: flex. Using jQuery's addClass() m ...

Partial element visibility while scrolling

My goal is to create a table with a fixed size that can be horizontally scrolled. I applied overflow-x: auto;, but only a part of the table is scrolling while the start of the table is off the screen. I am unable to provide the code, so I've added a s ...

Tips for Creating a Responsive Homepage

I'm new to CSS and trying to create a responsive design for mobile IE. Currently, the page appears blank on IE but works fine on Google Chrome and other browsers :-) Here are the code snippets I have used: HTML: <div class="main"> <div ...

Merging columns in Bootstrap 4 grid system

I have been working on creating a Bootstrap grid with the following structure: .facevalue { background: #ffffff61; font-family: Dubai; font-size: 18px; font-weight: 400; line-height: 30px; padding: 0 30px; border: 1px solid #e9e9e9; ma ...

What is preventing the question div and buttons from expanding according to their content?

After experimenting with setting the height of the question div to auto, I found that it would stretch to fit its content. However, I am looking for a solution without overflow: auto or scroll. Is there a limit to how responsive it can be once a certain ...

Tips for identifying when a video's autoplay feature does not function properly on all web browsers

My search for the most optimal method to automatically play a video in the background led me to discover some interesting findings based on the latest data available. VVC/x266 - Versatile Video Coding: Offers significant reduction in data requirements wi ...

Alert Message - Android Lollipop

Having trouble displaying a notification-type heads-up, and my attempts so far have not been successful. final Notification.Builder notif = new Builder(getApplicationContext()) .setContentTitle(getString(R.string.title)) .setContentText(getString( ...

Building a theme with TypeScript in React

As I embark on my React project, I've been tasked with creating a CSS using TypeScript while referring to the color palette diagram provided below. Utilizing createMuiTheme to build the theme, I've realized that there are various possible conditi ...

What is the best way to incorporate a button in my code that automatically triggers changes at regular intervals?

Is there a way to automatically change the color of my working traffic light in JavaScript on a timed basis, rather than relying solely on button clicks? Here is the current code I am using: <!DOCTYPE html> <html> <head> <style> # ...

Stop mega menu items from disappearing when hovered over

I'm currently working on a web page that features a mega menu. When I hover over the mega menu, it displays its items. However, when I try to hover over the items, they disappear. Here is the HTML code snippet: <li class="dropdown mega-dropdown m ...

Guide to importing external CSS styles into Angular 2 using the require method

I'm facing an issue with loading an external css file in different environment files. My setup includes two environments: development and production. Loading the css file locally works fine in development mode, but not in production mode. environment ...

What steps are needed to develop a proper HTML structure for this specific box in order to achieve the desired aesthetics?

Currently working on a box that includes various tags and an input field for adding new tags. The goal is to make this box resemble the tag form used on YouTube: https://i.stack.imgur.com/RSj2p.png This particular layout features a box with existing tags ...