【发布时间】:2019-03-18 12:40:44
【问题描述】:
这是我的 xml 代码:
<?xml version="1.0" encoding="utf-8"?>
<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"
android:background="@color/White">
<View
android:id="@+id/left"
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="120dp"
android:background="@android:color/holo_orange_dark"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintLeft_toRightOf="@+id/or"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/or"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:text="OR"
android:textSize="40sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/right"
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_marginTop="120dp"
android:layout_marginRight="10dp"
android:background="@android:color/holo_red_dark"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/or"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
根据上面的代码,视图是相互重叠的。我希望 textview 左侧有一个视图,而其他视图在右侧。
【问题讨论】:
标签: android android-layout android-view android-xml android-constraintlayout