Skip to content

Commit 56fe608

Browse files
committed
refactor: migrate main activity layout to ConstraintLayout
This commit replaces the root `LinearLayout` with `ConstraintLayout` in `activity_main.xml`. It adds the necessary constraint attributes to the child views (AdView, content frame, and the flash controls RelativeLayout) to maintain the layout structure.
1 parent 60b0baf commit 56fe608

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
xmlns:tools="http://schemas.android.com/tools"
55
android:id="@+id/layout_activity_main"
@@ -14,19 +14,29 @@
1414
android:layout_width="match_parent"
1515
android:layout_height="wrap_content"
1616
app:adSize="BANNER"
17-
app:adUnitId="@string/AdMob_Banner_Ads_ID" />
17+
app:adUnitId="@string/AdMob_Banner_Ads_ID"
18+
app:layout_constraintEnd_toEndOf="parent"
19+
app:layout_constraintStart_toStartOf="parent"
20+
app:layout_constraintTop_toTopOf="parent" />
1821

1922
<FrameLayout
2023
android:id="@+id/content_frame"
2124
android:layout_width="match_parent"
2225
android:layout_height="0dp"
23-
android:layout_weight="1" />
26+
android:layout_weight="1"
27+
app:layout_constraintBottom_toBottomOf="parent"
28+
app:layout_constraintEnd_toEndOf="parent"
29+
app:layout_constraintStart_toStartOf="parent"
30+
app:layout_constraintTop_toBottomOf="@id/adView" />
2431

2532
<RelativeLayout
2633
android:layout_width="wrap_content"
2734
android:layout_height="wrap_content"
2835
android:layout_gravity="center"
29-
android:paddingBottom="5dp">
36+
android:paddingBottom="5dp"
37+
app:layout_constraintBottom_toBottomOf="parent"
38+
app:layout_constraintEnd_toEndOf="parent"
39+
app:layout_constraintStart_toStartOf="parent">
3040

3141
<ImageView
3242
android:id="@+id/flashOff"
@@ -45,4 +55,4 @@
4555
android:src="@drawable/ic_flash_on" />
4656
</RelativeLayout>
4757

48-
</LinearLayout>
58+
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)