2
我的網格設計就是這樣。但是我想刪除網格元素兩邊的空格。 (黑標)不需要的Gridview間距
我想要的形象有點像爲GridView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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" >
<GridView
android:id="@+id/grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnWidth="100dip"
android:gravity="center"
android:numColumns="2"
android:stretchMode="spacingWidthUniform" />
</LinearLayout>
我格柵元素佈局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/grid_image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:contentDescription="@string/im" >
</ImageView>
<TextView
android:id="@+id/grid_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxLength="23"
android:gravity="center"
android:layout_marginTop="10sp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textSize="12sp" >
</TextView>
</LinearLayout>
我的XML佈局擴大
工作,是否有辦法引入像列線或薄空間列之間的分隔符。 –
你可以做的是將背景顏色設置爲gridview並將垂直和水平間距設置爲'1dp',我已經更新了我的答案 –
這樣做了,但在左側沒有間距(我更新了圖片)。此外,我想擴大圖像不僅水平,而且像擴大廣場,使它看起來不扭曲。 –