Я проектирую экран настроек. Поскольку вариантов может быть много, я поместил свой ConstraintLayout
в ScrollView
. Однако внизу есть огромное пустое пространство, от которого я не могу избавиться. Я уже добавил fillViewPort="true"
к ScrollView
, как предлагалось во многих других ответах по теме.
Вот мой файл макета:
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true">
<TextView
android:id="@+id/settings_security"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:text="Hello there"
android:textAllCaps="true"
android:textColor="@color/holo_blue_light"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.filecloud.android.components.TopTextView
android:id="@+id/settings_enable_lock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="8dp"
android:text="Hello there"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_security" />
<Switch
android:id="@+id/settings_enable_lock_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
app:layout_constraintBottom_toBottomOf="@id/settings_enable_lock"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/settings_enable_lock"
app:layout_constraintTop_toTopOf="@id/settings_enable_lock"
app:layout_constraintVertical_bias="0.5"
app:layout_constraintHorizontal_bias="1"/>
<FrameLayout
android:id="@+id/settings_change_lock"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="24dp"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_enable_lock_switch">
<com.filecloud.android.components.TopTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello there"
android:textSize="18sp" />
</FrameLayout>
<com.filecloud.android.components.TopTextView
android:id="@+id/settings_enable_integration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:text="Hello there"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_change_lock" />
<com.filecloud.android.components.TopTextView
android:id="@+id/settings_enable_integration_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:text="Hello there"
android:textSize="14sp"
android:textColor="@color/settings_hint"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_enable_integration" />
<Switch
android:id="@+id/settings_enable_integration_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/settings_enable_integration"
app:layout_constraintTop_toTopOf="@id/settings_enable_integration"
app:layout_constraintBottom_toBottomOf="@id/settings_enable_integration_hint"
app:layout_constraintVertical_bias="0.5"
app:layout_constraintHorizontal_bias="1" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/light_grey"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="@id/settings_enable_integration_hint" />
<TextView
android:id="@+id/settings_media_sync"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="32dp"
android:text="Hello there"
android:textAllCaps="true"
android:textColor="@color/holo_blue_light"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_enable_integration_hint" />
<com.filecloud.android.components.TopTextView
android:id="@+id/settings_enable_media_sync"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="8dp"
android:text="Hello there"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_media_sync" />
<com.filecloud.android.components.TopTextView
android:id="@+id/settings_enable_media_sync_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:text="Hello there"
android:textSize="14sp"
android:textColor="@color/settings_hint"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_enable_media_sync" />
<Switch
android:id="@+id/settings_enable_media_sync_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/settings_enable_media_sync"
app:layout_constraintTop_toTopOf="@id/settings_enable_media_sync"
app:layout_constraintBottom_toBottomOf="@id/settings_enable_media_sync_hint"
app:layout_constraintVertical_bias="0.5"
app:layout_constraintHorizontal_bias="1" />
<LinearLayout
android:id="@+id/settings_media_sync_source"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="24dp"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:clickable="true"
android:orientation="vertical"
android:foreground="?android:attr/selectableItemBackground"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_enable_media_sync_hint">
<com.filecloud.android.components.TopTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello there"
android:textSize="18sp" />
<com.filecloud.android.components.TopTextView
android:id="@+id/settings_media_sync_source_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/mediasync_default"
android:textSize="14sp"
android:textColor="@color/settings_hint"
android:textStyle="bold" />
</LinearLayout>
<com.filecloud.android.components.TopTextView
android:id="@+id/settings_media_sync_destination_folder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:text="Hello there"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_media_sync_source" />
<com.filecloud.android.components.TopTextView
android:id="@+id/settings_media_sync_destination_folder_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:text="Hello there"
android:textSize="14sp"
android:textColor="@color/settings_hint"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_media_sync_destination_folder" />
<FrameLayout
android:id="@+id/settings_media_sync_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="24dp"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_media_sync_destination_folder_hint">
<com.filecloud.android.components.TopTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello there"
android:textSize="18sp" />
</FrameLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/light_grey"
app:layout_constraintTop_toBottomOf="@id/settings_media_sync_status" />
<TextView
android:id="@+id/settings_offline_sync"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:text="Hello there"
android:textAllCaps="true"
android:textColor="@color/holo_blue_light"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_media_sync_status" />
<com.filecloud.android.components.TopTextView
android:id="@+id/settings_enable_auto_offline_sync"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="8dp"
android:text="Hello there"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_offline_sync" />
<com.filecloud.android.components.TopTextView
android:id="@+id/settings_enable_auto_offline_sync_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:text="Hello there"
android:textSize="14sp"
android:textColor="@color/settings_hint"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_enable_auto_offline_sync" />
<Switch
android:id="@+id/settings_enable_auto_offline_sync_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/settings_enable_auto_offline_sync"
app:layout_constraintTop_toTopOf="@id/settings_enable_auto_offline_sync"
app:layout_constraintBottom_toBottomOf="@id/settings_enable_auto_offline_sync_hint"
app:layout_constraintVertical_bias="0.5"
app:layout_constraintHorizontal_bias="1" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/light_grey"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="@id/settings_enable_auto_offline_sync_hint" />
<TextView
android:id="@+id/settings_data_usage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="32dp"
android:text="Hello there"
android:textAllCaps="true"
android:textColor="@color/holo_blue_light"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_enable_auto_offline_sync_hint" />
<com.filecloud.android.components.TopTextView
android:id="@+id/settings_enable_wifi_only"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="8dp"
android:text="Hello there"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_data_usage" />
<com.filecloud.android.components.TopTextView
android:id="@+id/settings_enable_wifi_only_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:text="Hello there"
android:textSize="14sp"
android:textColor="@color/settings_hint"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_enable_wifi_only" />
<Switch
android:id="@+id/settings_enable_wifi_only_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/settings_enable_wifi_only"
app:layout_constraintTop_toTopOf="@id/settings_enable_wifi_only"
app:layout_constraintBottom_toBottomOf="@id/settings_enable_wifi_only_hint"
app:layout_constraintVertical_bias="0.5"
app:layout_constraintHorizontal_bias="1" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
Результат:
Начальный экран
Полностью прокручен