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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:47:44+00:00 2026-06-17T17:47:44+00:00

< Edit > A new observation – I’ve tried the same ViewPager as stand

  • 0

< Edit >

  1. A new observation – I’ve tried the same ViewPager as stand alone Activity and as an AppWidget configuration view – and it crashes often as configuration view, while consistently runs well as a simple activity.

  2. Another observation – If the configuration layout is ViewPager as root, no crashes happened. if the ViewPager is embedded in FlowLayout or RelativeLayout – it crashes often.

< / Edit >

I’m using v4 ViewPager with PagerTabStrip in my AppWidget configuration xml, and it works perfectly most of the time.

However, I get this error (app crash) when some processing involved while loading the view:

 java.lang.IllegalStateException: Must measure with an exact width
    at android.support.v4.view.PagerTitleStrip.onMeasure(PagerTitleStrip.java:428)
    at android.view.View.measure(View.java:8335)
    at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1350)
    at android.view.View.measure(View.java:8335)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
    ...etc...

A code snippet from android.support.v4.view.PagerTitleStrip.onMeasure() –

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    //...

    if (widthMode != MeasureSpec.EXACTLY) {
        throw new IllegalStateException("Must measure with an exact width");
    }
    //...
}

How could I control the widthMode??

All the stack above is happening outside my code.

In my code I’ve tried to rule out many factors, and eventually I may have managed to isolate a root cause:

When I’m adding a mock “work” of 5 milis sleep per fragment (X30 fragments), I get the above error, and when removing it – the error seem gone.
Tried moving the work to onCreate() – didn’t make a difference

public static class TestFragment extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater,
            ViewGroup container, Bundle savedInstanceState) {

        View v = inflater.inflate(R.layout.splash, container, false);
        try {
            Thread.sleep(5); // << mock work causes quite consistent error
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        Log.i(TAG, "..onCreateView");

        return v;
    }
}

The actual work I’m doing on my real adapter’s fragment is minimal and can’t be avoided (setting the initial values which later populate the data in a background thread). So I don’t know how much more I can defer to a background thread.

Does anyone have experience with this?
Any idea why the above error occurs, and if it is possible to avoid it?

For reference (Not sure if it’s relevant):

<LinearLayout ...>
<android.support.v4.view.ViewPager
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    android:id="@+id/aw_pager"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1.0"
    android:background="@drawable/dialog_full_holo_dark"
    android:fadingEdge="horizontal"
    android:fadingEdgeLength="40dp" >

    <android.support.v4.view.PagerTabStrip
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="top" />
</android.support.v4.view.ViewPager>
</LinearLayout>
  • 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-17T17:47:45+00:00Added an answer on June 17, 2026 at 5:47 pm

    Solved at last! (2 days wasted on this):
    it was this line:

      android:background="@drawable/dialog_full_holo_dark"
    

    I replaced it with:

      android:background="@color/black"
    

    and the problem is gone.
    Nothing in the error has suggested that, and it wasn’t deterministic. Solved the hard way by elimination – add code > test > again…

    It is most likely a bug in Android code, probably some race condition in View layout management.

    Hope I saved 2 days for fellow devs bumping here.

    [Update]

    In another project I worked around this bug by wrapping the ViewPager with a FrameLayout. I set the background I needed to the FrameLayout, and set @color/transparent to the ViewPager.

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

Sidebar

Related Questions

Say I have two fields in a new or edit form: <%= f.text_field :email
This works: Entities.WorkOrderSet.Where(MyCustomMethod); This does not: Entities.WorkOrderSet.Where(o => MyCustomMethod(o)); ( [Edit] Even without new
EDIT: I added in where I create new instance of the class Process as
Whenever I try to edit existing or create new distribution provisioning profile on iOS
Why new()/delete() is slower than malloc()/free()? EDIT: Thanks for the answers so far. Please
EDIT : proper solution: void add(Student s) { if(root == null) root = new
I want to add a new form to the edit customer page, so far
edit/operacoes.php header('Content-Type: application/json'); include('../../lib/mysql.class.php'); $db = new MySQL(); if($db->Error()) $db->Kill(); //VARIÁVEIS DA FORM $id
I am quite new to client-side web development, so just feel free to edit
new_story GET /story/new(.:format) {:action=>new, :controller=>stories} edit_story GET /story/edit(.:format) {:action=>edit, :controller=>stories} story GET /story(.:format) {:action=>show,

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.