RelativeLayout 中的空 space
Empty space in RelativeLayout
我尝试用RelativeLayout
在另一个上面做一个图像,但是出现了不必要的空白space。
<?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:background="#263238"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingTop="12dp"
android:gravity="top">
<ImageView
android:id="@+id/heroImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/test3"
android:layout_alignParentTop="true"
android:scaleType="fitStart" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/corner" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFF"
android:id="@+id/linearlayout_hero">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hero Appearance"/>
</LinearLayout>
你可以在Wolverine
的图片和文字之间看到它。
用这个块替换你的底部线性布局
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#FFF"
android:id="@+id/linearlayout_hero">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hero Appearance"/>
</LinearLayout>
将此添加到您的 ImageView
android:scaleType="fitStart"
android:adjustViewBounds="true"
您可以像这样将 LinearLayout 放在 RelativeLayout 中:
<LinearLayout
android:id="@+id/linearlayout_hero"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/heroImage"
android:background="#FFF">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hero Appearance" />
</LinearLayout>
我正在尝试回答你的问题。
我认为是因为你的图片(hero/corner)底部有空白space,因为RelativeLayout的宽高是wrap content,所以RelativeLayout适合图片.
请检查你的图片:)
我尝试用RelativeLayout
在另一个上面做一个图像,但是出现了不必要的空白space。
<?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:background="#263238"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingTop="12dp"
android:gravity="top">
<ImageView
android:id="@+id/heroImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/test3"
android:layout_alignParentTop="true"
android:scaleType="fitStart" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/corner" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFF"
android:id="@+id/linearlayout_hero">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hero Appearance"/>
</LinearLayout>
你可以在Wolverine
的图片和文字之间看到它。
用这个块替换你的底部线性布局
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#FFF"
android:id="@+id/linearlayout_hero">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hero Appearance"/>
</LinearLayout>
将此添加到您的 ImageView
android:scaleType="fitStart"
android:adjustViewBounds="true"
您可以像这样将 LinearLayout 放在 RelativeLayout 中:
<LinearLayout
android:id="@+id/linearlayout_hero"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/heroImage"
android:background="#FFF">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hero Appearance" />
</LinearLayout>
我正在尝试回答你的问题。
我认为是因为你的图片(hero/corner)底部有空白space,因为RelativeLayout的宽高是wrap content,所以RelativeLayout适合图片.
请检查你的图片:)