android: Vertically scalable setup pages

Previously the setup pages would remain at a fixed height but now the icon and two text boxes will give up space as a device gets shorter. This eliminates the need for a scrolling view further problems with padding.
This commit is contained in:
Charles Lombardo 2023-04-26 01:54:55 -04:00 committed by bunnei
parent 48c506682d
commit f41939b66e
2 changed files with 45 additions and 23 deletions

View file

@ -10,7 +10,9 @@
android:id="@+id/viewPager2" android:id="@+id/viewPager2"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent" android:clipToPadding="false"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toTopOf="@+id/button_next"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@ -20,7 +22,7 @@
android:id="@+id/button_next" android:id="@+id/button_next"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="16dp" android:layout_margin="12dp"
android:text="@string/next" android:text="@string/next"
android:visibility="invisible" android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@ -31,7 +33,7 @@
android:id="@+id/button_back" android:id="@+id/button_back"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="16dp" android:layout_margin="12dp"
android:text="@string/back" android:text="@string/back"
android:visibility="invisible" android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"

View file

@ -1,40 +1,56 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat <androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:orientation="vertical"
android:paddingBottom="64dp">
<ImageView <ImageView
android:id="@+id/icon" android:id="@+id/icon"
android:layout_width="220dp" android:layout_width="0dp"
android:layout_height="220dp" android:layout_height="0dp"
android:layout_marginTop="64dp" android:layout_marginTop="64dp"
android:layout_gravity="center" /> android:layout_marginBottom="32dp"
app:layout_constraintBottom_toTopOf="@+id/text_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_max="220dp"
app:layout_constraintHeight_min="110dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="spread"
app:layout_constraintWidth_max="220dp"
app:layout_constraintWidth_min="110dp"
app:layout_constraintVertical_weight="3" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
style="@style/TextAppearance.Material3.DisplayMedium"
android:id="@+id/text_title" android:id="@+id/text_title"
android:layout_width="match_parent" style="@style/TextAppearance.Material3.DisplayMedium"
android:layout_height="wrap_content" android:layout_width="0dp"
android:layout_marginTop="64dp" android:layout_height="0dp"
android:textAlignment="center" android:textAlignment="center"
android:textColor="?attr/colorOnSurface" android:textColor="?attr/colorOnSurface"
android:textStyle="bold" android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/text_description"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/icon"
app:layout_constraintVertical_weight="1.3"
tools:text="@string/welcome" /> tools:text="@string/welcome" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
style="@style/TextAppearance.Material3.TitleLarge"
android:id="@+id/text_description" android:id="@+id/text_description"
android:layout_width="match_parent" style="@style/TextAppearance.Material3.TitleLarge"
android:layout_height="wrap_content" android:layout_width="0dp"
android:layout_marginTop="24dp" android:layout_height="0dp"
android:paddingHorizontal="32dp"
android:textAlignment="center" android:textAlignment="center"
android:textSize="26sp" android:textSize="26sp"
android:paddingHorizontal="16dp"
app:layout_constraintBottom_toTopOf="@+id/button_action"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text_title"
app:layout_constraintVertical_weight="2"
app:lineHeight="40sp" app:lineHeight="40sp"
tools:text="@string/welcome_description" /> tools:text="@string/welcome_description" />
@ -42,11 +58,15 @@
android:id="@+id/button_action" android:id="@+id/button_action"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="56dp" android:layout_height="56dp"
android:layout_marginTop="96dp"
android:layout_gravity="center"
android:textSize="20sp" android:textSize="20sp"
app:iconSize="24sp" android:layout_marginTop="16dp"
android:layout_marginBottom="48dp"
app:iconGravity="end" app:iconGravity="end"
app:iconSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text_description"
tools:text="Get started" /> tools:text="Get started" />
</androidx.appcompat.widget.LinearLayoutCompat> </androidx.constraintlayout.widget.ConstraintLayout>