My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 4773: IllegalStateException: View size is too small after padding
69 people starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----


Sign in to add a comment
 
Reported by [email protected], Jan 7, 2013
We are getting crash reports for this but until now have not found a way to reproduce it. I have no Idea where this goes wrong as it's somewhere internally in the maps api. A pointer to what we are doing wrong would be helpful.

java.lang.IllegalStateException: View size is too small after padding
at maps.am.r.b(Unknown Source)
at maps.y.t.b(Unknown Source)
at maps.y.t.a(Unknown Source)
at maps.y.q.a(Unknown Source)
at maps.y.au.a(Unknown Source)
at maps.y.ae.animateCameraWithCallback(Unknown Source)
at com.google.android.gms.maps.internal.IGoogleMapDelegate$Stub.onTransact(IGoogleMapDelegate.java:103)
at android.os.Binder.transact(Binder.java:297)
at com.google.android.gms.maps.internal.IGoogleMapDelegate$a$a.animateCameraWithCallback(Unknown Source)
at com.google.android.gms.maps.GoogleMap.animateCamera(Unknown Source)

Our code:

LatLng closestMarkerLatLng = new LatLng(parking.getLatitude(), parking.getLongitude());
LatLng currentLatLng = new LatLng(app.getLocation().getLatitude(), app.getLocation().getLongitude());
LatLngBounds latLngBounds = LatLngBounds.builder().include(currentLatLng).include(closestMarkerLatLng).build();

if(mMap!=null){
				if(getView().getMeasuredHeight()!=0 && getView().getMeasuredWidth()!=0){
					CameraUpdate update = CameraUpdateFactory.newLatLngBounds(latLngBounds, UIUtil.convertDpToPixel(100, getActivity()));
					mMap.animateCamera(update, new GoogleMap.CancelableCallback() {
						@Override
						public void onFinish() {
//							if the previous camera move is done, check the zoom level
							if(mMap.getCameraPosition().zoom >= MIN_ZOOM_LVL_TO_ZOOM_OUT){
								mMap.animateCamera(CameraUpdateFactory.zoomTo(DEFAULT_ZOOM));
							}
						}
						
						@Override
						public void onCancel() {
							// TODO Auto-generated method stub
						}
					});
				}
}

	public static int convertDpToPixel(float dp,Context context){
	    Resources resources = context.getResources();
	    DisplayMetrics metrics = resources.getDisplayMetrics();
	    Float px = dp * (metrics.densityDpi/160f);
	    return px.intValue();
	}


*********************************************************
For developers viewing this issue: please click the 'star' icon to be
notified of future changes, and to let us know how many of you are
interested in seeing it resolved.
*********************************************************
Jan 7, 2013
#1 [email protected]
Using getView().getMeasured[Height|Width]() is generally a bad idea as the returned dimensions don't reflect the actual width/height of the view. getMeasured[Height|Width]() returns the dimension after the measure pass while get[Width|Height]() returns the dimension after the layout pass.

If get[Width|Height]() is not fixing the issue, then you should probably make sure the width/height of your view is greater than 2 * 100dp

Nothing to do with your bug but please use the following method to scale a dimension (avoids useless boxing and division):

public static int convertDpToPixel(Context context, int dp) {
    (int) (dp * context.getResources().getDisplayMetrics().density + 0.5f);
}

Jan 7, 2013
#2 [email protected]
Thanks Cyril, I'll apply your suggestions and see if we still have the issue.
Jan 10, 2013
#3 [email protected]
Just got an other error report. I previously had this issue on a galaxy SII, the view is almost fullscreen so width and height should be greater than 2 * 100dp.
Jan 16, 2013
#4 [email protected]
I'm able to reproduce this and it's probably indeed related to the width/height of your view is not being greater than 2 * 100dp

This only happens when using the app in landscape mode on a low specs device where the tabs + action bar already take up half the screen
Jan 16, 2013
#5 [email protected]
I changed my code to:
int paddingInPixels = (int)(Math.min(getView().getWidth(), getView().getHeight()) * 0.1);

which fixes the problem
Nov 5, 2013
#7 [email protected]
I am getting same crash report even when padding is 0. 
Feb 25, 2014
#8 [email protected]
Hello,
I've got a bug email from a customer:
ANDROID_VERSION=4.3
APP_VERSION_NAME=2.2.1
BRAND=samsung
PHONE_MODEL=GT-I9505
CUSTOM_DATA=
STACK_TRACE=java.lang.IllegalStateException: View size is too small after padding
at maps.k.o.b(Unknown Source)
at maps.e.t.a(Unknown Source)
at maps.e.v.a(Unknown Source)
at maps.e.q.a(Unknown Source)
at maps.e.al.a(Unknown Source)
at eif.onTransact(SourceFile:83)
at android.os.Binder.transact(Binder.java:347)
at com.google.android.gms.maps.internal.IGoogleMapDelegate$a$a.moveCamera(Unknown Source)
at com.google.android.gms.maps.GoogleMap.moveCamera(Unknown Source)


The specified device is Samsung S4 so it not very low spec, and the app is running always in portrait mode.

Aug 15, 2014
#9 [email protected]
Any workarounds ?
Aug 21, 2014
#10 [email protected]
Experiencing the same issue on Samsung SII, landscape.
Sep 1, 2014
#11 [email protected]
Found  the same issue in Nexus 5 running Android 4.4.4, landscape mode
Sep 15, 2014
#12 [email protected]
Seeing this on a Samsung Exhibit (pretty small screen), but only on a restart of the activity. First time coming in, everything is perfect. But once the screen dims to black and you unlock the screen saver, the "java.lang.IllegalStateException: View size is too small after padding" happens. So, I'm catching this exception and just calling map.moveCamera with reduced padding (60). 

It works fine that way on this phone, but why does the padding need to be reduced when drawing this map after restart of the activity? I even tried recreating the map from scratch, but that made no difference.
Jun 29, 2015
#14 [email protected]
So i have faced a similar problem and my app crashes when my Phone goes into landscape mode or starts in landscape mode. This was mainly due to my code setting 

When portrait and landscape:
cameraUpdate = CameraUpdateFactory.newLatLngBounds(builder.build(), pinSpace.getWidth(), ((View) pinSpace.getParent()).getHeight() - pinSpace.getTop() * 2, 0);

I noticed there was a disportionate width and height assigned on landscape when compared to portrait.

The solution for me was to set cameraUpdate depending on orientation:
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
   cameraUpdate = CameraUpdateFactory.newLatLngBounds(builder.build(), pinSpace.getWidth(), ((View) pinSpace.getParent()).getHeight() - pinSpace.getTop() * 2, 0);
 } else {
    cameraUpdate = CameraUpdateFactory.newLatLngBounds(builder.build(), ((View) pinSpace.getParent()).getWidth() - pinSpace.getLeft() * 2, pinSpace.getHeight(), 0);
}

Hope this helps someone
Dec 10, 2015
#15 [email protected]
Same Issue Occured with me too ..

  if(distance>0&&distance<80){
     padding =250;
      BBApplication.getInstance().setMapPadding(padding);
                            
                        }

distance is in meter  padding =250;
     CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
      map.animateCamera(cu);
Feb 7, 2016
#16 [email protected]
Gotcha...breaking the law

Sign in to add a comment

Powered by Google Project Hosting