It seems like the unattended installation option only applies if you have fixed column widths set. Here is the only place in the GridView source code that uses the unattended setup option:
private boolean determineColumns(int availableSpace) { final int requestedHorizontalSpacing = mRequestedHorizontalSpacing; final int stretchMode = mStretchMode; final int requestedColumnWidth = mRequestedColumnWidth; boolean didNotInitiallyFit = false; if (mRequestedNumColumns == AUTO_FIT) { if (requestedColumnWidth > 0) {
This private function is called during the measurement / layout process. Note that in the auto-fit if statement, except for requestedColumnWidth > 0
, you get only 2 columns, what you see.
If a fixed width works for your application, you need to put it in your XML as follows:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <GridView android:id="@+id/gridView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="5dp" android:numColumns="auto_fit" android:columnWidth="30dp" android:verticalSpacing="10dp" android:horizontalSpacing="10dp"> </GridView> </FrameLayout>
source share