我想創建的類似於什麼是谷歌用來玩類似這樣的Android的問題,在GridView的
我使用的佈局和佈局得到的是這些卡網格佈局圖像大小:
對於GridView控件:
<RelativeLayout 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"
tools:context=".MainActivity"
android:background="#e5e5e5"
>
<GridView
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:columnWidth="60dp"
android:numColumns="2"
android:layout_marginLeft="2dp"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:stretchMode="columnWidth"
android:gravity="center"
/>
</RelativeLayout>
爲的GridItem:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_card"
>
<ImageView
android:id="@+id/imgIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
/>
<TextView
android:id="@+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:textSize="17sp"
android:layout_below="@id/imgIcon"
android:layout_marginTop="35dp"
android:layout_centerInParent="true"/>
</RelativeLayout>
,我得到的輸出是這樣的:
,我使用的影像尺寸爲356x500。 (我獲得使用300×300稍微好大小電網) 是我面臨的問題是:
- 1.As此圖片顯示,該卡是太大,有很多空格的圖像和周圍圖像不適合在谷歌播放商店 。我如何讓這張卡片適合 圖片。白色空間量隨圖像大小的變化而變化。
- 該卡卡在屏幕的左邊緣。我如何保持屏幕邊緣和卡之間的間距。
請幫我解決這個問題。 感謝
中做同樣的事情,但是對於兩張卡之間的空間不是這樣嗎?我將它改爲1dp,但圖像周圍的每張卡片中仍有很多空白區域。謝謝 –
我仍然得到相同的結果。圖像周圍仍有很多空白區域,只改變間距會減少卡片之間的空間。 –
空間取決於您的屏幕大小以及每行和圖像大小有多少圖像 –