制約レイアウトを使用して下にスクロールできるレイアウトを作成したいのですが、方法がわかりません。 は次のようScrollView
に の親である必要がありますかConstraintLayout
?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:fillViewport="true">
<android.support.constraint.ConstraintLayout
android:id="@+id/Constraint"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
それともその逆でしょうか? 誰かこれに関する良いチュートリアルを教えてくれたり、例を挙げてくれたりできるかもしれませんが、見つけることができません。
また、これがバグなのか、それとも私が設定していない設定なのかはわかりませんが、次のような画像を見たことがあります。
ブループリントの「青い四角形」の外側にいくつかのコンポーネントがありますが、それらは表示されます。一方、私の側では、コンポーネントを「白いスペース」に配置すると、それを表示したり、どこにも移動したりすることはできませんが、コンポーネント ツリーに表示されます。
アップデート :
デザイン ツールで制約レイアウトをスクロール可能にする方法を見つけました。水平ガイドラインを使用して制約レイアウトの境界を押し下げ、デバイスを超えて拡張します。その後、ガイドラインを制約レイアウトの新しい下部として使用して、コンポーネントを固定できます。
ベストアンサー1
動作しているようですが、どのような依存関係で作業していたのかはわかりませんが、この
compile 'com.android.support.constraint:constraint-layout:1.0.2'
うまくいっています、これが私がやったことです
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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"
tools:context=".MainActivity">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:id="@+id/til_input"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="Escriba el contenido del archivo"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/btn_save"
app:layout_constraintTop_toTopOf="@id/btn_save"
app:layout_constraintVertical_chainStyle="spread">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/btn_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClickButtonSave"
android:text="Guardar"
app:layout_constraintLeft_toRightOf="@+id/til_input"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/txt_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/til_input"
app:layout_constraintVertical_chainStyle="spread"
app:layout_constraintVertical_weight="1" />
<Button
android:id="@+id/btn_delete"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:onClick="onClickButtonDelete"
android:text="Eliminar"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/txt_content"
app:layout_constraintVertical_chainStyle="spread" />
</android.support.constraint.ConstraintLayout>
</ScrollView>