Skip to content

Commit f5bd6df

Browse files
Refactor AboutFragment layout
This commit refactors `fragment_about.xml` by: - Replacing the root `ConstraintLayout` with a `LinearLayoutCompat` for simpler vertical arrangement. - Setting `android:fillViewport="true"` on the `FastScrollScrollView`. - Adding `android:animateLayoutChanges="true"` to the `MaterialCardView`. - Grouping chips into nested `LinearLayoutCompat` containers for better organization. - Removing explicit `app:layout_constraintTop_toTopOf` and similar constraints, relying on the `LinearLayoutCompat`'s orientation.
1 parent 2b2a75e commit f5bd6df

File tree

1 file changed

+113
-124
lines changed

1 file changed

+113
-124
lines changed

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

Lines changed: 113 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,31 @@
44
xmlns:tools="http://schemas.android.com/tools"
55
android:id="@+id/scroll_view"
66
android:layout_width="match_parent"
7-
android:layout_height="match_parent">
7+
android:layout_height="match_parent"
8+
android:fillViewport="true">
89

9-
<androidx.constraintlayout.widget.ConstraintLayout
10+
<androidx.appcompat.widget.LinearLayoutCompat
11+
android:id="@+id/content_container"
1012
android:layout_width="match_parent"
1113
android:layout_height="wrap_content"
12-
android:layout_marginHorizontal="24dp"
13-
android:layout_marginVertical="24dp">
14+
android:orientation="vertical"
15+
android:paddingHorizontal="24dp"
16+
android:paddingVertical="24dp">
1417

1518
<com.google.android.material.card.MaterialCardView
1619
android:id="@+id/card_view_about"
1720
style="@style/Widget.Material3.CardView.Filled"
1821
android:layout_width="match_parent"
1922
android:layout_height="wrap_content"
23+
android:animateLayoutChanges="true"
2024
app:contentPadding="16dp"
21-
app:layout_constraintTop_toTopOf="parent"
2225
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.CardViewTopRoundedFilled">
2326

24-
<androidx.constraintlayout.widget.ConstraintLayout
27+
<androidx.appcompat.widget.LinearLayoutCompat
2528
android:layout_width="match_parent"
26-
android:layout_height="wrap_content">
29+
android:layout_height="wrap_content"
30+
android:gravity="center_horizontal"
31+
android:orientation="vertical">
2732

2833
<androidx.appcompat.widget.AppCompatImageView
2934
android:id="@+id/image_view_app_icon"
@@ -35,9 +40,6 @@
3540
android:focusable="true"
3641
android:src="@mipmap/ic_launcher"
3742
android:tooltipText="@string/tooltip_open_me"
38-
app:layout_constraintEnd_toEndOf="parent"
39-
app:layout_constraintStart_toStartOf="parent"
40-
app:layout_constraintTop_toTopOf="parent"
4143
tools:targetApi="26" />
4244

4345
<com.google.android.material.textview.MaterialTextView
@@ -47,8 +49,7 @@
4749
android:layout_marginTop="16dp"
4850
android:gravity="center"
4951
android:text="@string/app_name"
50-
android:textStyle="bold"
51-
app:layout_constraintTop_toBottomOf="@id/image_view_app_icon" />
52+
android:textStyle="bold" />
5253

5354
<com.google.android.material.textview.MaterialTextView
5455
android:id="@+id/text_view_app_version"
@@ -58,128 +59,121 @@
5859
android:drawableStart="@drawable/ic_data_object"
5960
android:drawablePadding="4dp"
6061
android:gravity="center"
61-
android:text="@string/app_version"
62-
app:layout_constraintEnd_toEndOf="parent"
63-
app:layout_constraintStart_toStartOf="parent"
64-
app:layout_constraintTop_toBottomOf="@id/text_view_app_title" />
65-
66-
<com.google.android.material.chip.Chip
67-
android:id="@+id/chip_google_dev"
68-
style="@style/Widget.Material3.Chip.Assist.Elevated"
69-
android:layout_width="wrap_content"
70-
android:layout_height="wrap_content"
71-
android:layout_marginStart="16dp"
72-
android:layout_marginTop="8dp"
73-
android:minHeight="0dp"
74-
android:text="@string/google_dev"
75-
android:tooltipText="@string/google_dev"
76-
app:chipIcon="@drawable/ic_google_dev"
77-
app:chipSpacing="0dp"
78-
app:layout_constraintEnd_toStartOf="@id/chip_youtube"
79-
app:layout_constraintHorizontal_chainStyle="packed"
80-
app:layout_constraintStart_toStartOf="parent"
81-
app:layout_constraintTop_toBottomOf="@id/text_view_app_version"
82-
tools:targetApi="26" />
62+
android:text="@string/app_version" />
8363

84-
<com.google.android.material.chip.Chip
85-
android:id="@+id/chip_youtube"
86-
style="@style/Widget.Material3.Chip.Assist.Elevated"
64+
<androidx.appcompat.widget.LinearLayoutCompat
8765
android:layout_width="wrap_content"
8866
android:layout_height="wrap_content"
89-
android:layout_marginHorizontal="16dp"
9067
android:layout_marginTop="8dp"
91-
android:minHeight="0dp"
92-
android:text="@string/youtube"
93-
android:tooltipText="@string/youtube"
94-
app:chipIcon="@drawable/ic_youtube"
95-
app:chipSpacing="0dp"
96-
app:layout_constraintEnd_toEndOf="parent"
97-
app:layout_constraintStart_toEndOf="@id/chip_google_dev"
98-
app:layout_constraintTop_toBottomOf="@id/text_view_app_version"
99-
tools:targetApi="26" />
100-
101-
<com.google.android.material.chip.Chip
102-
android:id="@+id/chip_github"
103-
style="@style/Widget.Material3.Chip.Assist.Elevated"
104-
android:layout_width="wrap_content"
105-
android:layout_height="wrap_content"
106-
android:layout_marginStart="16dp"
107-
android:minHeight="0dp"
108-
android:text="@string/github"
109-
android:tooltipText="@string/github"
110-
app:chipIcon="@drawable/ic_github"
111-
app:chipSpacing="0dp"
112-
app:layout_constraintEnd_toStartOf="@id/chip_twitter"
113-
app:layout_constraintHorizontal_chainStyle="packed"
114-
app:layout_constraintStart_toStartOf="parent"
115-
app:layout_constraintTop_toBottomOf="@id/chip_google_dev"
116-
tools:targetApi="26" />
117-
118-
<com.google.android.material.chip.Chip
119-
android:id="@+id/chip_twitter"
120-
style="@style/Widget.Material3.Chip.Assist.Elevated"
121-
android:layout_width="wrap_content"
122-
android:layout_height="wrap_content"
123-
android:layout_marginHorizontal="16dp"
124-
android:minHeight="0dp"
125-
android:text="@string/twitter"
126-
android:tooltipText="@string/twitter"
127-
app:chipIcon="@drawable/ic_twitter"
128-
app:chipSpacing="0dp"
129-
app:layout_constraintEnd_toEndOf="parent"
130-
app:layout_constraintStart_toEndOf="@id/chip_github"
131-
app:layout_constraintTop_toBottomOf="@id/chip_google_dev"
132-
tools:targetApi="26" />
133-
134-
<com.google.android.material.chip.Chip
135-
android:id="@+id/chip_xda"
136-
style="@style/Widget.Material3.Chip.Assist.Elevated"
68+
android:gravity="center"
69+
android:orientation="horizontal">
70+
71+
<com.google.android.material.chip.Chip
72+
android:id="@+id/chip_google_dev"
73+
style="@style/Widget.Material3.Chip.Assist.Elevated"
74+
android:layout_width="wrap_content"
75+
android:layout_height="wrap_content"
76+
android:layout_marginEnd="16dp"
77+
android:minHeight="0dp"
78+
android:text="@string/google_dev"
79+
android:tooltipText="@string/google_dev"
80+
app:chipIcon="@drawable/ic_google_dev"
81+
app:chipSpacing="0dp"
82+
tools:targetApi="26" />
83+
84+
<com.google.android.material.chip.Chip
85+
android:id="@+id/chip_youtube"
86+
style="@style/Widget.Material3.Chip.Assist.Elevated"
87+
android:layout_width="wrap_content"
88+
android:layout_height="wrap_content"
89+
android:minHeight="0dp"
90+
android:text="@string/youtube"
91+
android:tooltipText="@string/youtube"
92+
app:chipIcon="@drawable/ic_youtube"
93+
app:chipSpacing="0dp"
94+
tools:targetApi="26" />
95+
</androidx.appcompat.widget.LinearLayoutCompat>
96+
97+
<androidx.appcompat.widget.LinearLayoutCompat
13798
android:layout_width="wrap_content"
13899
android:layout_height="wrap_content"
139-
android:layout_marginStart="16dp"
140-
android:minHeight="0dp"
141-
android:text="@string/xda"
142-
android:tooltipText="@string/xda"
143-
app:chipIcon="@drawable/ic_xda"
144-
app:chipSpacing="0dp"
145-
app:layout_constraintEnd_toStartOf="@id/chip_music"
146-
app:layout_constraintHorizontal_chainStyle="packed"
147-
app:layout_constraintStart_toStartOf="parent"
148-
app:layout_constraintTop_toBottomOf="@id/chip_github"
149-
tools:targetApi="26" />
150-
151-
<com.google.android.material.chip.Chip
152-
android:id="@+id/chip_music"
153-
style="@style/Widget.Material3.Chip.Assist.Elevated"
100+
android:layout_marginTop="8dp"
101+
android:gravity="center"
102+
android:orientation="horizontal">
103+
104+
<com.google.android.material.chip.Chip
105+
android:id="@+id/chip_github"
106+
style="@style/Widget.Material3.Chip.Assist.Elevated"
107+
android:layout_width="wrap_content"
108+
android:layout_height="wrap_content"
109+
android:layout_marginEnd="16dp"
110+
android:minHeight="0dp"
111+
android:text="@string/github"
112+
android:tooltipText="@string/github"
113+
app:chipIcon="@drawable/ic_github"
114+
app:chipSpacing="0dp"
115+
tools:targetApi="26" />
116+
117+
<com.google.android.material.chip.Chip
118+
android:id="@+id/chip_twitter"
119+
style="@style/Widget.Material3.Chip.Assist.Elevated"
120+
android:layout_width="wrap_content"
121+
android:layout_height="wrap_content"
122+
android:minHeight="0dp"
123+
android:text="@string/twitter"
124+
android:tooltipText="@string/twitter"
125+
app:chipIcon="@drawable/ic_twitter"
126+
app:chipSpacing="0dp"
127+
tools:targetApi="26" />
128+
</androidx.appcompat.widget.LinearLayoutCompat>
129+
130+
<androidx.appcompat.widget.LinearLayoutCompat
154131
android:layout_width="wrap_content"
155132
android:layout_height="wrap_content"
156-
android:layout_marginHorizontal="16dp"
157-
android:minHeight="0dp"
158-
android:text="@string/music"
159-
android:tooltipText="@string/music"
160-
app:chipIcon="@drawable/ic_album"
161-
app:chipSpacing="0dp"
162-
app:layout_constraintEnd_toEndOf="parent"
163-
app:layout_constraintStart_toEndOf="@id/chip_xda"
164-
app:layout_constraintTop_toBottomOf="@id/chip_github"
165-
tools:targetApi="26" />
166-
</androidx.constraintlayout.widget.ConstraintLayout>
133+
android:layout_marginTop="8dp"
134+
android:gravity="center"
135+
android:orientation="horizontal">
136+
137+
<com.google.android.material.chip.Chip
138+
android:id="@+id/chip_xda"
139+
style="@style/Widget.Material3.Chip.Assist.Elevated"
140+
android:layout_width="wrap_content"
141+
android:layout_height="wrap_content"
142+
android:layout_marginEnd="16dp"
143+
android:minHeight="0dp"
144+
android:text="@string/xda"
145+
android:tooltipText="@string/xda"
146+
app:chipIcon="@drawable/ic_xda"
147+
app:chipSpacing="0dp"
148+
tools:targetApi="26" />
149+
150+
<com.google.android.material.chip.Chip
151+
android:id="@+id/chip_music"
152+
style="@style/Widget.Material3.Chip.Assist.Elevated"
153+
android:layout_width="wrap_content"
154+
android:layout_height="wrap_content"
155+
android:minHeight="0dp"
156+
android:text="@string/music"
157+
android:tooltipText="@string/music"
158+
app:chipIcon="@drawable/ic_album"
159+
app:chipSpacing="0dp"
160+
tools:targetApi="26" />
161+
</androidx.appcompat.widget.LinearLayoutCompat>
162+
</androidx.appcompat.widget.LinearLayoutCompat>
167163
</com.google.android.material.card.MaterialCardView>
168164

169165
<com.d4rk.androidtutorials.java.ads.views.NativeAdBannerView
170166
android:id="@+id/ad_view"
171167
android:layout_width="match_parent"
172168
android:layout_height="wrap_content"
173169
android:layout_marginTop="2dp"
174-
app:layout_constraintTop_toBottomOf="@id/card_view_about"
175170
app:nativeAdLayout="@layout/ad_about" />
176171

177172
<com.airbnb.lottie.LottieAnimationView
178173
android:id="@+id/animation_about"
179174
android:layout_width="match_parent"
180175
android:layout_height="192dp"
181176
android:layout_marginTop="24dp"
182-
app:layout_constraintTop_toBottomOf="@id/ad_view"
183177
app:lottie_autoPlay="true"
184178
app:lottie_rawRes="@raw/anim_about"
185179
app:lottie_speed="0.48" />
@@ -189,26 +183,21 @@
189183
android:layout_width="match_parent"
190184
android:layout_height="wrap_content"
191185
android:layout_marginTop="24dp"
192-
android:src="@drawable/il_about"
193-
app:layout_constraintTop_toBottomOf="@id/animation_about" />
186+
android:src="@drawable/il_about" />
194187

195188
<com.google.android.material.textview.MaterialTextView
196189
android:id="@+id/text_view_made_in"
197190
android:layout_width="wrap_content"
198191
android:layout_height="wrap_content"
192+
android:layout_gravity="center_horizontal"
199193
android:layout_marginTop="24dp"
200-
android:text="@string/made_in"
201-
app:layout_constraintEnd_toEndOf="parent"
202-
app:layout_constraintStart_toStartOf="parent"
203-
app:layout_constraintTop_toBottomOf="@id/illustration_about" />
194+
android:text="@string/made_in" />
204195

205196
<com.google.android.material.textview.MaterialTextView
206197
android:id="@+id/text_view_copyright"
207198
android:layout_width="wrap_content"
208199
android:layout_height="wrap_content"
209-
android:text="@string/copyright"
210-
app:layout_constraintEnd_toEndOf="parent"
211-
app:layout_constraintStart_toStartOf="parent"
212-
app:layout_constraintTop_toBottomOf="@id/text_view_made_in" />
213-
</androidx.constraintlayout.widget.ConstraintLayout>
214-
</me.zhanghai.android.fastscroll.FastScrollScrollView>
200+
android:layout_gravity="center_horizontal"
201+
android:text="@string/copyright" />
202+
</androidx.appcompat.widget.LinearLayoutCompat>
203+
</me.zhanghai.android.fastscroll.FastScrollScrollView>

0 commit comments

Comments
 (0)