여기에 3 개 전망과 함께 Constraintlayout입니다 :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="match_parent">
<ImageView
android:id="@+id/iv_profile_image"
android:layout_width="100dp"
android:layout_height="100dp"
app:layout_constraintBottom_toTopOf="@+id/tv_name"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/iv_profile_image" />
<TextView
android:id="@+id/tv_headline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/tv_name" />
</android.support.constraint.ConstraintLayout>
결과 :
당신이 볼 수 있듯이, 각 뷰 사이에 큰 차이가있다. 이러한 틈을 제거하고 화면 중앙에 배치하려면 어떻게합니까? RelativeLayout 또는 LinearLayout을 사용하여이 작업을 쉽게 수행 할 수 있지만이 ConstraintLayout에서 어떻게 할 수 있습니까? ConstraintLayout이 RelativeLayout을 대신한다고 생각하십니까?