我有一个 GridView
,我使用 BaseAdapter
来调整我的 GridView
中的图像和文本。我有一个问题,当我运行我的应用程序时,我的“GridView”有左、右、上和下边距。我不需要这些边距。
这是我的 xml
来源:
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/strada_grid_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#d6d6d6"
android:gravity="center"
android:horizontalSpacing="1dp"
android:numColumns="2"
android:verticalSpacing="1dp" >
</GridView>
GridView
适配器 xml
代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="120dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#ffffff" >
<TextView
android:id="@+id/desc1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/photo1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="-27dp"
android:text="Hello"
android:textColor="#3d3b3b"
android:textSize="12dp" />
<TextView
android:id="@+id/stradaID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/desc1"
android:layout_alignParentBottom="true"
android:text="TextView"
android:textColor="#000000"
android:visibility="gone" />
<ImageView
android:id="@+id/photo1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="38dp" />
</RelativeLayout>
</RelativeLayout>
我该如何解决我的问题?
最佳答案
我在项目位置 /res/values/dimens.xml 中将默认边距设置为 0,它对我有用。
<资源>
<dimen name="activity_horizontal_margin">0dp</dimen>
<dimen name="activity_vertical_margin">0dp</dimen>
/资源>
关于Android GridView 全屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24951552/