0
대형 화면에서는 가로로, 작은 화면에서는 세로로 단추를 배치하고 싶습니다 (화면 해상도에 맞지 않는 경우). 화면 해상도에 의존하는 xml에 두 개의 레이아웃을 만들지 않고 ConstraintLayout을 사용하여이 작업을 수행 할 수 있습니까? 그 동작에 대해 "제약 조건"을 어떻게 설정할 수 있습니까?ConstraintLayout에서 하나의 단추를 다른 단추보다 아래쪽에 배치하면 화면에 맞지 않습니다.
그것은 당신이 할 수 없습니다 XML
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First button"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/button3" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Second button"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/button5"
app:layout_constraintRight_toRightOf="parent" />
</android.support.constraint.ConstraintLayout>
버튼의 정적 너비를 설정 했습니까? –
버튼의 너비와 높이는 "wrap_content"에 있습니다. 나는 또한 질문에 XML을 추가했습니다. – lukjar