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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:10:36+00:00 2026-06-17T13:10:36+00:00

Android design pattern guide says widget’s content and layout can be dynamically adjusted to

  • 0

Android design pattern guide says widget’s content and layout can be dynamically adjusted to the size the user defined through resize operation here: Design guide for widgets

Example provided in the design guide:
Example image provided in the design guide.

But I do not see anything in the docs as to how to accomplish this. How do we change the layout as per resize operation? Any ideas regarding the approach will be appreciated.

  • 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-17T13:10:37+00:00Added an answer on June 17, 2026 at 1:10 pm

    Thanks to A–C , this is possible for Jellybean and above devices and is simple to implement.
    Below is the sample code using onAppWidgetOptionsChanged method

    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    @Override
    public void onAppWidgetOptionsChanged(Context context,
            AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) {
    
        Log.d(DEBUG_TAG, "Changed dimensions");
    
        // See the dimensions and
        Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId);
    
        // Get min width and height.
        int minWidth = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH);
        int minHeight = options
                .getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT);
    
                // Obtain appropriate widget and update it.
        appWidgetManager.updateAppWidget(appWidgetId,
                getRemoteViews(context, minWidth, minHeight));
    
        super.onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId,
                newOptions);
    }
    
    /**
     * Determine appropriate view based on width provided.
     * 
     * @param minWidth
     * @param minHeight
     * @return
     */
    private RemoteViews getRemoteViews(Context context, int minWidth,
            int minHeight) {
        // First find out rows and columns based on width provided.
        int rows = getCellsForSize(minHeight);
        int columns = getCellsForSize(minWidth);
    
        if (columns == 4) {
            // Get 4 column widget remote view and return
        } else {
                        // Get appropriate remote view.
            return new RemoteViews(context.getPackageName(),
                    R.layout.quick_add_widget_3_1);
        }
    }
    
    /**
     * Returns number of cells needed for given size of the widget.
     * 
     * @param size Widget size in dp.
     * @return Size in number of cells.
     */
     private static int getCellsForSize(int size) {
      int n = 2;
      while (70 * n - 30 < size) {
        ++n;
      }
      return n - 1;
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The on/off switches shown on http://developer.android.com/design/building-blocks/switches.html#switches are awesome. I can't figure out how to
Possible Duplicate: Android Layout and positioning issue Design layout which support for all kind
I want to design a login and register layout using android tabs. Image is
From Android widget screen guidelines, http://developer.android.com/guide/practices/ui_guidelines/widget_design.html , we know that, home screen has 4*4
I'm trying to design an Android layout that would look like the following: Entity1
Android got XML layout design with a tool that allow you to drop and
A design pattern I've noticed being used recently in some Android apps is a
Can we consider an AsynchTask in Android like realization of a command pattern? Does
Are there any tools that can be used to design Android UI's (like the
'Android Design' site is recommending 'Boundary feedback' for scrollable view. http://developer.android.com/design/style/touch-feedback.html https://i.stack.imgur.com/TuBkX.png is there

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.