<?xml version = "1.0" encoding = "utf-8"?>
<androidx.constraintlayout.widget.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"
android:layout_marginStart = "@dimen/dp_16"
android:layout_marginTop = "@dimen/dp_32"
android:layout_marginEnd = "@dimen/dp_16"
android:layout_marginBottom = "@dimen/dp_40"
android:focusableInTouchMode = "true">
<TextView
android:id = "@+id/tv_header"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:lineSpacingExtra = "4sp"
android:text = "HEADER"
android:textColor = "#333333"
android:textSize = "20sp"
android:textStyle = "bold"
app:layout_constraintEnd_toEndOf = "parent"
app:layout_constraintStart_toStartOf = "parent"
app:layout_constraintTop_toTopOf = "parent" />
<ScrollView
android:id = "@+id/scrollable"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:layout_marginTop = "@dimen/dp_18"
app:layout_constraintEnd_toEndOf = "parent"
app:layout_constraintStart_toStartOf = "parent"
app:layout_constrainedHeight = "true"
android:layout_marginBottom = "@dimen/dp_40"
app:layout_constraintTop_toBottomOf = "@+id/tv_header">
<TextView
android:id = "@+id/tv_text"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = "@string/very_long_text"
android:textColor = "#666666"
android:textSize = "16sp"
android:textStyle = "normal" />
</ScrollView>
<TextView
android:id = "@+id/tv_footer"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:lineSpacingExtra = "4sp"
android:text = "Footer"
android:textColor = "#00539f"
android:textSize = "16sp"
android:textStyle = "bold"
app:layout_constraintBottom_toBottomOf = "parent"
app:layout_constraintStart_toStartOf = "parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Это мой макет. Я хочу установить фиксированный заголовок в верхнем фиксированном нижнем колонтитуле внизу и прокручиваемый очень длинный текст в теле, но когда я использовал нижний нижний колонтитул кода, он перекрывается с основным текстом. Может ли кто-нибудь предложить, какие свойства мне не хватает? хочу использовать только ConstraintLayout
без родственника или Linearlayout
Вам нужно установить нижние ограничения scrollView на верхние ограничения нижнего колонтитула.
<?xml version = "1.0" encoding = "utf-8"?><?xml version = "1.0" encoding = "utf-8"?>
<androidx.constraintlayout.widget.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"
android:layout_marginStart = "@dimen/dp_16"
android:layout_marginTop = "@dimen/dp_32"
android:layout_marginEnd = "@dimen/dp_16"
android:layout_marginBottom = "@dimen/dp_40"
android:focusableInTouchMode = "true">
<TextView
android:id = "@+id/tv_header"
android:layout_width = "wrap_content"
android:layout_height = "0dp"
android:lineSpacingExtra = "4sp"
android:text = "HEADER"
android:textColor = "#333333"
android:textSize = "20sp"
android:textStyle = "bold"
app:layout_constraintEnd_toEndOf = "parent"
app:layout_constraintStart_toStartOf = "parent"
app:layout_constraintTop_toTopOf = "parent" />
<ScrollView
android:id = "@+id/scrollable"
android:layout_width = "wrap_content"
android:layout_height = "0dp"
android:layout_marginTop = "@dimen/dp_18"
android:layout_marginBottom = "@dimen/dp_40"
app:layout_constrainedHeight = "true"
app:layout_constraintBottom_toTopOf = "@+id/tv_footer"
app:layout_constraintEnd_toEndOf = "parent"
app:layout_constraintStart_toStartOf = "parent"
app:layout_constraintTop_toBottomOf = "@+id/tv_header">
<TextView
android:id = "@+id/tv_text"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = "@string/very_long_text"
android:textColor = "#666666"
android:textSize = "16sp"
android:textStyle = "normal" />
</ScrollView>
<TextView
android:id = "@+id/tv_footer"
android:layout_width = "wrap_content"
android:layout_height = "0dp"
android:lineSpacingExtra = "4sp"
android:text = "Footer"
android:textColor = "#00539f"
android:textSize = "16sp"
android:textStyle = "bold"
app:layout_constraintBottom_toBottomOf = "parent"
app:layout_constraintStart_toStartOf = "parent"
app:layout_constraintTop_toBottomOf = "@+id/scrollable" />
</androidx.constraintlayout.widget.ConstraintLayout>