java RelataiveLayout定位
我正在尝试使用Android XML布局模板实现布局:
我现在有XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:tools="http://schemas.安卓.com/tools"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:layout_marginBottom="12dp"
安卓:layout_marginTop="0dp"
安卓:background="@color/grey"
安卓:clickable="true"
安卓:orientation="horizontal"
安卓:padding="0dp">
<RelativeLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:tools="http://schemas.安卓.com/tools"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_centerInParent="false"
安卓:layout_centerVertical="true"
安卓:layout_marginBottom="0dp"
安卓:duplicateParentState="true"
安卓:orientation="horizontal"
安卓:gravity="center_horizontal"
安卓:paddingTop="@dimen/schedule_row_paddingtop">
<RelativeLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:tools="http://schemas.安卓.com/tools"
安卓:layout_width="wrap_content"
安卓:layout_height="@dimen/home_row_teamLogoHeight"
安卓:layout_centerInParent="false"
安卓:layout_centerVertical="true"
安卓:layout_marginBottom="0dp"
安卓:duplicateParentState="true"
安卓:orientation="horizontal"
安卓:gravity="center_horizontal"
安卓:paddingTop="6dp">
<ImageView
安卓:id="@+id/teamALogo"
安卓:layout_width="wrap_content"
安卓:layout_height="match_parent"
安卓:scaleType="fitCenter"
安卓:src="@drawable/france_logo"
安卓:visibility="visible" />
</RelativeLayout>
<TextView
安卓:id="@+id/programmeSport"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:ellipsize="end"
安卓:maxLines="1"
安卓:text="sport"
安卓:gravity="center_horizontal"
安卓:textColor="@color/yellow"
安卓:textAllCaps="true"
安卓:textSize="@dimen/home_row_league_title"
安卓:textStyle="bold" />
<TextView
安卓:id="@+id/programmeTitle"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:layout_below="@+id/programmeSport"
安卓:ellipsize="end"
安卓:gravity="center_horizontal"
安卓:maxLines="1"
安卓:text="programme title"
安卓:textColor="@color/white"
安卓:layout_marginTop="-4dip"
安卓:textSize="@dimen/home_row_programmeTitle"
/>
<TextView
安卓:id="@+id/programmeDay"
安卓:layout_height="wrap_content"
安卓:text="2:30 PM"
安卓:textAllCaps="true"
安卓:gravity="center_horizontal"
安卓:layout_marginTop="-6dp"
安卓:textColor="@color/green"
安卓:textSize="@dimen/home_row_date"
安卓:layout_below="@+id/programmeTitle"
安卓:layout_width="match_parent"
/>
<RelativeLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:tools="http://schemas.安卓.com/tools"
安卓:layout_width="wrap_content"
安卓:layout_height="@dimen/home_row_teamLogoHeight"
安卓:layout_centerInParent="false"
安卓:layout_centerVertical="true"
安卓:layout_marginBottom="0dp"
安卓:duplicateParentState="true"
安卓:orientation="horizontal"
安卓:gravity="right"
安卓:paddingTop="6dp">
<ImageView
安卓:id="@+id/teamBLogo"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:scaleType="fitCenter"
安卓:src="@drawable/italy_logo"
安卓:layout_alignParentRight="true"
安卓:gravity="center_horizontal"
安卓:visibility="visible" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
目前它看起来不太好,因为存在一些重叠,在更大的屏幕上,“A队徽标”和“B队徽标”浮动到屏幕边缘(按计划浮动在文本的左侧和右侧),除了中间的文本之外,还留下了一个巨大的游戏:
Sample output of the issue in Android device
我需要的图像,浮动在左侧和右侧,以在同一位置垂直为每个夹具,并为他们与“队v队B”水平线
任何帮助都将不胜感激
谢谢
# 1 楼答案
您应该遵循ConstraintLayout或LinearLayout以实现所需的输出。 你可以像下面这样做