The Views of a GridView overlap when run on one (real) device running at 1024x600 and mdpi
but are correct
on another (also real) device running at 1280x720 and xhdpi as well as on several emulators, including one for the device producing the error.
Where does one start to look for the source of the problem? The layout of the GridView is a harmless
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:columnWidth="90dp"
android:numColumns="auto_fit"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:stretchMode="columnWidth"
android:gravity="center"
/>
and, in this brief example, the adapter is equally simple.
public View getView( int position, View convertView, ViewGroup parent ) {
MyView myView;
if( convertView == null ) { // if it's not recycled, initialize some attributes
myView = new MyView( context );
myView.setLayoutParams( new GridView.LayoutParams(150, 150) );
myView.setPadding( 8, 8, 8, 8 );
} else {
myView = (MyView) convertView;
}
return myView;
}