【发布时间】:2017-07-30 22:29:14
【问题描述】:
我有一个具有以下布局的 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布局。 -
添加完整版面
-
可能是你的可绘制图像有填充检查它,使用方向水平到线性布局
标签: android android-layout android-linearlayout