无论我在layout_height
中输入什么内容,ConstraintLayout
的高度似乎与手机屏幕尺寸相同。有什么方法可以设计它来自动调整其高度与其内容的总高度?
<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"
tools:context="stfn.personaltrainer.activities.Training">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="10dp">
<TextView
android:id="@+id/exerciceName"
android:layout_width="277dp"
android:layout_height="41dp"
android:layout_marginTop="4dp"
android:text="Exercice name"
android:textAlignment="center"
android:textSize="36sp"
app:layout_constraintHorizontal_bias="0.504"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!-- TextViews, Buttons, etc. -->
<Button
android:id="@+id/repetitionsDone"
android:layout_width="118dp"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:onClick="goToNextSeries"
android:text="@string/done"
android:textAppearance="@style/TextAppearance.AppCompat.Button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/repetitionsInCurrentSeries" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
答案 0 :(得分:0)
更改布局的高度,以使整个屏幕充满:
android:layout_height="match_parent"