Android 如何删除Tablelayout中两行之间的空间?
我使用Android 如何删除Tablelayout中两行之间的空间?,android,android-tablelayout,Android,Android Tablelayout,我使用Tablelayout在屏幕上显示了6个不同的图像。这是我的xml代码 <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"
Tablelayout
在屏幕上显示了6个不同的图像。这是我的xml代码
<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"
android:background="@color/background"
android:orientation="vertical"
tools:context=".MainMenu" >
<TableLayout
android:id="@+id/tableLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<ImageView
android:id="@+id/image1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:contentDescription="@string/app_name"
android:src="@drawable/temp" />
<ImageView
android:id="@+id/image2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:contentDescription="@string/app_name"
android:src="@drawable/temp" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<ImageView
android:id="@+id/image3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:contentDescription="@string/app_name"
android:src="@drawable/temp" />
<ImageView
android:id="@+id/image4"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:contentDescription="@string/app_name"
android:src="@drawable/temp" />
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<ImageView
android:id="@+id/image5"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:contentDescription="@string/app_name"
android:src="@drawable/temp" />
<ImageView
android:id="@+id/image6"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:contentDescription="@string/app_name"
android:src="@drawable/temp" />
</TableRow>
</TableLayout>
</LinearLayout>
输出如下图所示
我想删除两行之间的空格。如何操作?从
表格布局
和表格行
中删除所有边距和填充
<TableLayout
android:padding="0dip" <!-- add this -->
android:layout_margin="0dip" <!-- add this -->
android:id="@+id/tableLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:id=“@+id/tableLayout”
android:layout\u width=“匹配父项”
android:layout\u height=“match\u parent”>
和
android:id=“@+id/tableRow3”
android:layout\u width=“包装内容”
android:layout\u height=“0dp”
android:layout_weight=“1”>
对于所有的表行尝试将此属性添加到所有ImageView和xml中您好,您还有其他选择吗?尝试添加此android:scaleType=“fitXY”所有ImageView和xml中的属性没有为任何视图提供填充和边距,因此在java代码中添加了填充和边距?@Haresh,伟大的工作人员,您能将其作为答案发布,以便我可以接受它吗?这非常有效,不确定我们是否可以为其添加边框以更好地控制图像显示
<TableRow
android:padding="0dip" <!-- add this -->
android:layout_margin="0dip" <!-- add this -->
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >