간단한 레이아웃이 있습니다. 더 왼쪽과 오른쪽 여백이없는 당신이 볼 수 있듯이 디자인보기에서ConstraintLayout 여백
<?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"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorDarkGray">
<RelativeLayout
android:id="@+id/container3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:alpha="0.7"
android:fontFamily="sans-serif"
android:letterSpacing="0.03"
android:text="Another text"
android:textColor="@color/colorWhite"
android:textSize="11sp"
android:textStyle="normal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:fontFamily="sans-serif"
android:letterSpacing="0.03"
android:text="Some text"
android:textColor="@color/colorWhite"
android:textSize="11sp"
android:textStyle="normal" />
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
, 그것은 너무 보인다. 상단 및 하단 여백이 잘 작동합니다. 왼쪽 또는 오른쪽 여백을 제거하면 상대 레이아웃이 화면을 약간 넘어서 이동합니다. 상대 레이아웃이 없어도 할 수있을 것 같지만, 그 이유는 무엇인지 관심이 있습니다.
RelativeLayout 너비를 부모 (0dp)와 일치하도록 설정하십시오. – FarshidABZ
이렇게하면 textView를 부모 오른쪽과 왼쪽으로 정렬하고 RelativeLayout이 wrap_content 인 경우가 발생합니다. – FarshidABZ