Skip to content

Commit

Permalink
Hide the bottom navigation container if there are no visible buttons. (
Browse files Browse the repository at this point in the history
…google#2453)

* Hide bottomnavigation container if no buttons are visible.

* use constraintlayout to fix the issue.

* Change the constraints according to Submit button.

* Rmove redundant attributes.

---------

Co-authored-by: Santosh Pingle <spingle@google.com>
  • Loading branch information
santosh-pingle and Santosh Pingle authored Mar 14, 2024
1 parent 6ca5cbc commit 4742e60
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
29 changes: 19 additions & 10 deletions datacapture/src/main/res/layout/questionnaire_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,11 @@
app:layout_constraintBottom_toTopOf="@id/bottom_nav_container"
/>

<LinearLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/bottom_nav_container"
style="?attr/questionnaireBottomNavContainerStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
>
Expand All @@ -89,12 +87,9 @@
android:layout_marginHorizontal="@dimen/action_button_margin_horizontal"
android:layout_marginVertical="@dimen/action_button_margin_vertical"
android:text="@string/cancel_questionnaire"
/>

<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>

<Button
Expand All @@ -103,6 +98,9 @@
android:layout_marginHorizontal="@dimen/action_button_margin_horizontal"
android:layout_marginVertical="@dimen/action_button_margin_vertical"
android:text="@string/button_pagination_previous"
app:layout_constraintEnd_toStartOf="@+id/pagination_next_button"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>

<Button
Expand All @@ -111,6 +109,9 @@
android:layout_marginHorizontal="@dimen/action_button_margin_horizontal"
android:layout_marginVertical="@dimen/action_button_margin_vertical"
android:text="@string/button_pagination_next"
app:layout_constraintEnd_toStartOf="@+id/submit_questionnaire"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>

<Button
Expand All @@ -119,16 +120,24 @@
android:layout_marginHorizontal="@dimen/action_button_margin_horizontal"
android:layout_marginVertical="@dimen/action_button_margin_vertical"
android:text="@string/button_review"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>

<Button
android:id="@+id/submit_questionnaire"
style="?attr/questionnaireSubmitButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/action_button_margin_horizontal"
android:layout_marginVertical="@dimen/action_button_margin_vertical"
android:text="@string/submit_questionnaire"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>

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

</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 1 addition & 1 deletion datacapture/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<!-- Action button -->
<dimen name="action_button_margin_horizontal">16dp</dimen>
<dimen name="action_button_margin_vertical">8dp</dimen>
<dimen name="action_button_margin_vertical">16dp</dimen>

<!-- Header -->
<dimen name="error_text_at_header_margin_top">4dp</dimen>
Expand Down
6 changes: 0 additions & 6 deletions datacapture/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,6 @@

<style name="Questionnaire.BottomNavContainerStyle" parent="">
<item name="android:background">?attr/colorSurface</item>
<item
name="android:paddingTop"
>@dimen/bottom_container_padding_vertical</item>
<item
name="android:paddingBottom"
>@dimen/bottom_container_padding_vertical</item>
</style>

<style
Expand Down

0 comments on commit 4742e60

Please sign in to comment.