我有以下布局一个ListView:线性布局中删除元件之间的间隔
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginTop="1dp"
android:layout_marginBottom="1dp"
android:src="@drawable/ok" >
</ImageView>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="@+id/label"
android:textSize="20dp" >
</TextView>
</LinearLayout>
这将产生以下布局:
但我想摆脱空的空间放在图像的左侧,并将文字放在图像旁边:
我已经尝试设置填充和边距为0dp,但没有奏效。
编辑:我张贴的LinearLayout是ConstraintLayout的一部分:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.beric.listviewtest.MyListActivity"
tools:showIn="@layout/activity_my_list">
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/feed_fragment_portrait"
class="com.beric.listviewtest.MyListFragment"/>
</android.support.constraint.ConstraintLayout>
发布你的'ListView'布局。 –
添加完整的布局 –
可能是您的可绘制图像有填充检查它,使用方向水平线性布局 – dharmx