The Problem
I'm having a weird issue that I can't figure out and need some other eyes to look at. I have dynamically created a ProgressBar view and it works on a variety of devices and AVDs except for my Motorola Xoom.
Screenshots
All screenshots have the device name above them and have been reduced around 50% from whatever it grabbed through the ADT except for the Nexus 10 which is 25% because of it's super high resolution. The red background for the ProgressBar is added for debug purposes to show that the view is there and visible. I added left and top padding to center it.
Screenshots below starting with the Xoom where it does not work and followed by Nexus 10 (AVD), Nexus 7, Galaxy Nexus and HTC Droid Incredible demonstrating it working everywhere else. After the shots I'll add my code.
Motorola Xoom Not Working
Progress bar not working! But note the view is visible (we see the red background).
Working Fine On Other Devices
The circle progress is visible on all of these devices.
Simulated Samsung Nexus 10
ASUS Nexus 7
Samsung Galaxy Nexus
HTC Droid Incredible
Now the code
This creates the parent view that contains it:
RelativeLayout discoverListLayout = new RelativeLayout(mContext);
discoverListLayout.setLayoutParams(params);
discoverListLayout.addView(mDiscoverList);
mDiscoverList is a list view that is ultimately displayed. The ProgressBar is loaded on top of it until the list is loaded.
Now create and setup the progress bar. I setup the padding onGlobalLayout because otherwise the objects have 0 width and height.
mDiscoverLoading = new ProgressBar(mContext);
params.height = ViewPager.LayoutParams.WRAP_CONTENT;
params.width = ViewPager.LayoutParams.WRAP_CONTENT;
mDiscoverLoading.setLayoutParams(params);
mDiscoverLoading.setIndeterminate(true);
discoverListLayout.addView(mDiscoverLoading);
ViewTreeObserver vto = mDiscoverLoading.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@SuppressWarnings("deprecation")
@Override
public void onGlobalLayout() {
if (mDiscoverList.getCount() > 0) {
processLoadedList(true);
} else {
mDiscoverLoading.setBackgroundColor(getActivity().getResources().getColor(R.color.stitchoid_red));
mDiscoverLoading.setPadding((getView().getWidth() / 2) - (mDiscoverLoading.getWidth() / 2),(getView().getHeight() / 2) - (mDiscoverLoading.getHeight()), 0, 0);
}
ViewTreeObserver obs = mDiscoverLoading.getViewTreeObserver();
obs.removeGlobalOnLayoutListener(this);
}
});
So again everything works like a champ except on the Motorola Xoom!? I would be grateful for any insights or suggestions to help solve this problem. Please let me know if I should provide any additional information.
Thank you very much!
*Addendum: A weird thing of note that is probably not very relevant but just in case: if I set the ProgressBar width to match_parent (and don't add width padding) it also works everywhere else but then on the Xoom it does show but is distorted as it's stretched to the width (xoom only).