Androidのグリッド表示レイアウトに問題があります。私はグリッドビューで余分なスペースを排除するための解決策を見つけることができません。私は多くのもの(numColumns、columnWidth、stretchMode、重力)と(StackOverflowからの)アドバイスを試みましたが、何も正しく動作しません。私はこの問題で約8時間を費やしました。私もprogramically余分なスペース削減しようとしたGridViewと余分なスペースが埋め込まれています
<GridView
android:id="@+id/lookbook_gridview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:listSelector="@null"
android:padding="0dip"
android:layout_margin="0dip"
android:verticalSpacing="0px"
android:horizontalSpacing="0px"
android:numColumns="auto_fit"
android:columnWidth="160px"
android:stretchMode="columnWidth"
android:gravity="center"
android:layout_gravity="center"
android:background="#000"
android:cacheColorHint="#000"
android:descendantFocusability="afterDescendants"
android:layout_alignParentTop="true"
android:layout_above="@id/buttons">
</GridView>
:ここではグリッドビューのコードである
private void setGridview()
{
GridView gridview = (GridView) findViewById(R.id.lookbook_gridview);
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
int gridSize = display.getWidth();
int count = gridSize/160; // image has 160x160 px
int colWidth = (gridSize/count) - PADDING;
gridview.setColumnWidth(colWidth);
gridview.setNumColumns(count);
}
は、しかし、それは私のHTCの欲望(右)上でのみ動作しますが、エミュレータ(左)との同じディスプレイの解像度と同じAPIバージョン - それは動作していません。
誰かがすべての解像度とデバイスで正常に動作するように特別なパディングやスペースなしのGridViewの画像を設定する方法を、知っていますか?私の問題を解決するために
私の答えは[this] [1]スレッドでご覧ください。 [1]:https://stackoverflow.com/questions/6876861/removing-the-extra-padding-in-a-gridview-in-android/27321360#27321360 –