Skip to content
This repository was archived by the owner on Jul 2, 2025. It is now read-only.

Commit f704af2

Browse files
bringToFront
1 parent c348d48 commit f704af2

File tree

3 files changed

+20
-31
lines changed

3 files changed

+20
-31
lines changed

android/canonical/app/src/main/java/com/google/samples/quickstart/canonical/MainActivity.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class MainActivity : AppCompatActivity() {
1616
val runFragment = RunFragment()
1717
supportFragmentManager
1818
.beginTransaction()
19-
.replace(R.id.content_view, runFragment)
19+
.replace(R.id.fragment_container, runFragment)
2020
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
2121
.commit()
2222

@@ -25,41 +25,42 @@ class MainActivity : AppCompatActivity() {
2525
when (item.itemId) {
2626

2727
R.id.bottom_navigation_item_run -> {
28-
val autocompleteFrameLayout : FrameLayout = findViewById(R.id.autocomplete_view)
28+
val autocompleteFrameLayout : FrameLayout = findViewById(R.id.autocomplete_container)
2929
autocompleteFrameLayout.visibility = View.INVISIBLE
3030

3131
val runFragment = RunFragment()
3232
supportFragmentManager
3333
.beginTransaction()
34-
.replace(R.id.content_view, runFragment)
34+
.replace(R.id.fragment_container, runFragment)
3535
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
3636
.commit()
3737
true
3838
}
3939

4040
R.id.bottom_navigation_item_map -> {
41-
val autocompleteFrameLayout : FrameLayout = findViewById(R.id.autocomplete_view)
41+
val autocompleteFrameLayout : FrameLayout = findViewById(R.id.autocomplete_container)
4242
autocompleteFrameLayout.visibility = View.VISIBLE
43+
autocompleteFrameLayout.bringToFront()
4344

4445
val mapsFragment = MapsFragment()
4546
val autocompleteFragment = AutocompleteFragment()
4647
supportFragmentManager
4748
.beginTransaction()
48-
.replace(R.id.content_view, mapsFragment)
49-
.replace(R.id.autocomplete_view, autocompleteFragment)
49+
.replace(R.id.fragment_container, mapsFragment)
50+
.replace(R.id.autocomplete_container, autocompleteFragment)
5051
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
5152
.commit()
5253
true
5354
}
5455

5556
R.id.bottom_navigation_item_profile -> {
56-
val autocompleteFrameLayout : FrameLayout = findViewById(R.id.autocomplete_view)
57+
val autocompleteFrameLayout : FrameLayout = findViewById(R.id.autocomplete_container)
5758
autocompleteFrameLayout.visibility = View.INVISIBLE
5859

5960
val meFragment = MeFragment()
6061
supportFragmentManager
6162
.beginTransaction()
62-
.replace(R.id.content_view, meFragment)
63+
.replace(R.id.fragment_container, meFragment)
6364
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
6465
.commit()
6566
true

android/canonical/app/src/main/res/layout/activity_main.xml

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,19 @@
1919
android:id="@+id/fragment_container"
2020
android:layout_width="match_parent"
2121
android:layout_height="0dp"
22-
android:measureAllChildren="true"
2322
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation_view"
2423
app:layout_constraintTop_toTopOf="parent">
2524

26-
<androidx.constraintlayout.widget.ConstraintLayout
27-
android:layout_width="match_parent"
28-
android:layout_height="match_parent"
29-
android:orientation="vertical"
30-
tools:context=".MainActivity">
31-
32-
<FrameLayout
33-
android:id="@+id/autocomplete_view"
34-
android:layout_width="match_parent"
35-
android:layout_height="wrap_content"
36-
app:layout_constraintTop_toTopOf="parent"/>
37-
38-
<FrameLayout
39-
android:id="@+id/content_view"
40-
android:layout_width="match_parent"
41-
android:layout_height="0dp"
42-
app:layout_constraintBottom_toBottomOf="parent"
43-
app:layout_constraintTop_toTopOf="parent" />
44-
45-
</androidx.constraintlayout.widget.ConstraintLayout>
46-
4725
</FrameLayout>
26+
<FrameLayout
27+
android:id="@+id/autocomplete_container"
28+
android:layout_width="match_parent"
29+
android:layout_height="wrap_content"
30+
android:measureAllChildren="true"
31+
android:background="@android:color/white"
32+
app:layout_constraintTop_toTopOf="parent">
33+
34+
</FrameLayout>
4835

4936

5037
</androidx.constraintlayout.widget.ConstraintLayout>

android/canonical/app/src/main/res/layout/fragment_maps.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
2+
<fragment
3+
xmlns:android="http://schemas.android.com/apk/res/android"
34
xmlns:tools="http://schemas.android.com/tools"
45
android:id="@+id/map"
56
android:name="com.google.android.gms.maps.SupportMapFragment"

0 commit comments

Comments
 (0)