摆脱垂直 LinearLayout 中图像和文本之间的空白
Get rid of whitespace between Image and text in a vertical LinearLayout
我有一个 ImageView
和 2 个 TextViews
垂直 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:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical" >
<ImageView
android:id="@+id/logo"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center" />
<TextView
android:id="@+id/players"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="88dp"
android:maxLines="15"
android:text="TextView"
android:textStyle="bold" />
<TextView
android:id="@+id/subs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Subs" />
</LinearLayout>
我的图片和下面的文字之间的白色太多了space。正在将图像调整为 ImageView
。我已经更改了背景颜色:并且图像看起来不错:占用图像的预期 space,仅此而已。从其他问题来看,我已经尝试 ImageView
的 android:adjustViewBounds
属性,但这并没有什么不同。
您看到白色 space 的原因是 players
TextView 中的以下属性:
android:layout_marginTop="88dp"
根据需要删除它或减少 space。
我有一个 ImageView
和 2 个 TextViews
垂直 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:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical" >
<ImageView
android:id="@+id/logo"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center" />
<TextView
android:id="@+id/players"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="88dp"
android:maxLines="15"
android:text="TextView"
android:textStyle="bold" />
<TextView
android:id="@+id/subs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Subs" />
</LinearLayout>
我的图片和下面的文字之间的白色太多了space。正在将图像调整为 ImageView
。我已经更改了背景颜色:并且图像看起来不错:占用图像的预期 space,仅此而已。从其他问题来看,我已经尝试 ImageView
的 android:adjustViewBounds
属性,但这并没有什么不同。
您看到白色 space 的原因是 players
TextView 中的以下属性:
android:layout_marginTop="88dp"
根据需要删除它或减少 space。