Skip to content

Commit

Permalink
Better tablet layout
Browse files Browse the repository at this point in the history
  • Loading branch information
AChep committed Apr 23, 2022
1 parent 1b2372b commit 9636a31
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 42 deletions.
44 changes: 36 additions & 8 deletions app/src/main/res/layout/activity_donate.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent">
Expand All @@ -13,7 +12,7 @@
app:liftOnScroll="true">

<com.google.android.material.appbar.CollapsingToolbarLayout
style="?attr/collapsingToolbarLayoutLargeStyle"
style="@style/ToolbarStyle"
android:layout_width="match_parent"
android:layout_height="?attr/collapsingToolbarLayoutLargeSize"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
Expand All @@ -24,20 +23,49 @@
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:navigationIcon="@drawable/ic_arrow_back"
app:title="@string/help_donate" />
app:title="@string/help_donate"
app:titleCentered="@bool/titleCentered" />

</com.google.android.material.appbar.CollapsingToolbarLayout>

</com.google.android.material.appbar.AppBarLayout>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
<androidx.core.widget.NestedScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingTop="16dp"
android:paddingBottom="16dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false">

<LinearLayout
android:id="@+id/scrollViewContent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:orientation="vertical"
android:paddingTop="16dp"
android:paddingBottom="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_max="@dimen/sheetMaxWidth">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:nestedScrollingEnabled="false" />

</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.core.widget.NestedScrollView>

<ProgressBar
android:id="@+id/progressView"
Expand Down
58 changes: 34 additions & 24 deletions app/src/main/res/layout/activity_lab.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent">
Expand All @@ -13,7 +12,7 @@
app:liftOnScroll="true">

<com.google.android.material.appbar.CollapsingToolbarLayout
style="?attr/collapsingToolbarLayoutLargeStyle"
style="@style/ToolbarStyle"
android:layout_width="match_parent"
android:layout_height="?attr/collapsingToolbarLayoutLargeSize"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
Expand All @@ -24,7 +23,8 @@
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:navigationIcon="@drawable/ic_arrow_back"
app:title="@string/help_test" />
app:title="@string/help_test"
app:titleCentered="@bool/titleCentered" />

</com.google.android.material.appbar.CollapsingToolbarLayout>

Expand All @@ -37,32 +37,42 @@
android:clipToPadding="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<LinearLayout
android:id="@+id/scrollViewContent"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:orientation="vertical">
android:layout_height="wrap_content">

<TextView
android:layout_width="match_parent"
<LinearLayout
android:id="@+id/scrollViewContent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:text="@string/lab_sensors"
android:textAppearance="?textAppearanceLabelMedium"
android:textColor="?colorTertiary" />
android:clipToPadding="false"
android:orientation="vertical"
android:paddingTop="16dp"
android:paddingBottom="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_max="@dimen/sheetMaxWidth">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/sensorsRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:nestedScrollingEnabled="false" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="@string/lab_sensors"
android:textAppearance="?textAppearanceLabelMedium"
android:textColor="?colorTertiary" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/sensorsRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:nestedScrollingEnabled="false" />

</LinearLayout>
</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.core.widget.NestedScrollView>

Expand Down
11 changes: 6 additions & 5 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
app:liftOnScroll="true">

<com.google.android.material.appbar.CollapsingToolbarLayout
style="?attr/collapsingToolbarLayoutLargeStyle"
style="@style/ToolbarStyle"
android:layout_width="match_parent"
android:layout_height="?attr/collapsingToolbarLayoutLargeSize"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
Expand All @@ -23,7 +23,8 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:title="@string/app_name" />
app:title="@string/app_name"
app:titleCentered="@bool/titleCentered" />

</com.google.android.material.appbar.CollapsingToolbarLayout>

Expand All @@ -42,16 +43,16 @@

<LinearLayout
android:id="@+id/scrollViewContent"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/sheetMarginStart"
android:clipToPadding="false"
android:orientation="vertical"
android:paddingTop="16dp"
android:paddingBottom="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_max="520dp">
app:layout_constraintWidth_max="@dimen/sheetMaxWidth">

<com.google.android.material.card.MaterialCardView
android:id="@+id/warContainer"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-ru/strings_war.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
<string name="war_title" translatable="false">Разработка и поддержка приложения может быть остановлена навсегда.</string>
<string name="war_text" translatable="false">Мой дом сейчас под обстрелом российской армией. Выходите на улицы, что бы остановить войну!</string>
<string name="war_learn_more" translatable="false">Что происходит?</string>
<string name="war_learn_more_url" translatable="false">https://www.youtube.com/watch?v=9F5ZmLhIy8E</string>

</resources>
4 changes: 0 additions & 4 deletions app/src/main/res/values-w580dp/dimens.xml

This file was deleted.

11 changes: 11 additions & 0 deletions app/src/main/res/values-w640dp/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="ToolbarStyle" parent="Widget.Material3.CollapsingToolbar.Large">
<item name="collapsedTitleGravity">center</item>
<item name="expandedTitleGravity">center_horizontal|bottom</item>
</style>

<item name="titleCentered" type="bool">true</item>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<resources>
<dimen name="actionBarSize">56dp</dimen>
<dimen name="sheetMarginStart">0dp</dimen>
<dimen name="sheetMaxWidth">640dp</dimen>
<dimen name="cardMarginHorizontal">16dp</dimen>
<dimen name="cardCornerRadius">24dp</dimen>

Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,11 @@
<style name="ButtonElevated" parent="Widget.Material3.Button.ElevatedButton">
</style>

<style name="ToolbarStyle" parent="Widget.Material3.CollapsingToolbar.Large">
<item name="collapsedTitleGravity">start|center_vertical</item>
<item name="expandedTitleGravity">start|bottom</item>
</style>

<item name="titleCentered" type="bool">false</item>

</resources>

0 comments on commit 9636a31

Please sign in to comment.