응용 프로그램 레이아웃을 만들 때 내 응용 프로그램에 ConstraintLayout
을 사용하고 있습니다. 나는 하나의 EditText
과 Button
이 가운데에 있어야하고 Button
이 EditText
아래에 있어야하며 화면 상단에 16dp의 여백 만있는 화면을 만들려고합니다.ConstraintLayout에 요소를 가운데에 배치하는 방법
여기 내 레이아웃과 스크린 샷이 지금보고 있습니다.
당신은 EDITTEXT 50 % 위치에서 수평 가이드 라인을 사용하여 제약 조건을 하단과 상단 (8dp)를 추가 할 수 있습니다
<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:paddingLeft="16dp"
android:paddingRight="16dp"
tools:context="com.icici.iciciappathon.login.AuthenticationActivity">
<android.support.design.widget.TextInputLayout
android:id="@+id/client_id_input_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/login_client_id"
android:inputType="textEmailAddress" />
</android.support.design.widget.TextInputLayout>
<android.support.v7.widget.AppCompatButton
android:id="@+id/authenticate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/login_auth"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="@id/client_id_input_layout"
app:layout_constraintRight_toRightOf="@id/client_id_input_layout"
app:layout_constraintTop_toTopOf="@id/client_id_input_layout" />
</android.support.constraint.ConstraintLayout>
감사합니다. @Pycpik'
'layout_constraintGuide_percent'의 사용법은 무엇입니까? –
'Guideline '은보기를 고정시킬 수있는 보이지 않는 항목입니다. 'layout_constraintGuide_percent'는 부모의 백분율입니다. 여기 0.5 높이 50 %입니다 – Pycpik