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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:42:05+00:00 2026-06-04T23:42:05+00:00

I am trying to create an ImageView that is resized when the user presses

  • 0

I am trying to create an ImageView that is resized when the user presses a MenuItem. I tried to use the following code, but I get an error and my application stops.

@Override
public boolean onOptionsItemSelected(MenuItem item)
{
    switch(item.getItemId())
    {
        case R.id.sub_item_25_percent:
            try
            {
            LayoutParams params = new LayoutParams(imageView1.getLayoutParams());
            params.width = Pages.PAGE_WIDTH_25_PERCENT;
            params.height = Pages.PAGE_HEIGHT_25_PERCENT;

            imageView1.setLayoutParams(params);
            }
            catch(Exception ex)
            {
                Toast.makeText(this, ex.getMessage(), Toast.LENGTH_SHORT);
            }
            break;
     }       

}

As you can see, I already used a try-catch-block to get informations about the exception, but the application is still just stopping without displaying the Toast.

Does anyone have a clue what I could do to fix my problem?

  • 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-04T23:42:08+00:00Added an answer on June 4, 2026 at 11:42 pm

    Try this:

    @Override
    public boolean onOptionsItemSelected(MenuItem item)  
    {
        switch(item.getItemId())
        {
            case R.id.sub_item_25_percent:
    
                imageView1.getLayoutParams().width = Pages.PAGE_WIDTH_25_PERCENT;
                imageView1.getLayoutParams().height = Pages.PAGE_HEIGHT_25_PERCENT;
    
                imageView1.requestLayout();
    
            break;
         }       
    

    }

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

Sidebar

Related Questions

I'm trying to create moving functionality to my imageView (maskPreview in the code below),
Trying to create a widget with custom fonts, but read that widget doesn't support
I'm trying to create a widget that contains a single ImageView which, when clicked,
I'm trying to create a drawable from an ImageView I know that we can
I'm trying create a gui using Tkinter that grabs a username and password and
Trying to create a regex pattern for email address check. That will allow a
Trying to create Database as follows: USE Master GO IF NOT EXISTS(SELECT [Name] FROM
I'm trying to create an Android app that adds a random quote to images.
I am trying to create a drawable in code and change the color based
I'm trying to place various size images inside imageView of UITableViewCell. I get the

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.