Okay, so you decide to use the measure() method of the View class in order to get the Adapter item view’s width and height.
In Lollipop devices, it works but when you deploy it some other device or emulator on pre-Lollipop devices, it gives out a NullPointerException when inflating.
This error message is very confusing as it does not pinpoint you to the exact problem in the XML file. The problem though, is not within the XML file layout.
This occurs when your layout is a RelativeLayout and the reason for this is that Inflater does not extract layout_width and layout_height attributes when you do not assign its parent as an argument in the inflate method.
The solution to this problem is to call setLayoutParams() with the specified width and height and then call measure().
That should fix it. Even a width and height of 0 will do the trick.
There are times when we do not want the EditText component to gain focus and have the input keyboard show up.
What I wanted was the input keyboard to only show up when I tap on the EditText component.
Well, there is a solution to this without using code. Just add the attribute android:focusableInTouchMode=”true” in your layout where the EditText is part of and it won’t show the keyboard whenever the Activity starts.
There is no method to automatically change your Android app’s container size for showing Google AdMob ads. While it does re-adjust itself whenever the orientation changes, it does not resize itself to the correct size.
Try changing your device’s orientation from portrait to landscape mode and you will see that the height is the same. The result is that the height of the ad container shown is too big just like when its orientation is in portrait mode.
The workaround to make the ad container resize correctly according to orientation change like the image below is to remove the ad container in your layout view and add it back.
Say this is your code for adding the ad container view to your layout view.