Skip to content

Commit b2fd6a7

Browse files
refactor: polish native ad visuals
1 parent 1e7f3e1 commit b2fd6a7

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
<com.google.android.material.card.MaterialCardView
88
android:id="@+id/ad_card"
99
style="@style/Widget.Material3.CardView.Elevated"
10+
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.CardViewBottomRounded"
1011
android:layout_width="match_parent"
1112
android:layout_height="wrap_content"
12-
android:layout_margin="16dp"
13-
app:cardCornerRadius="24dp"
13+
android:layout_marginHorizontal="24dp"
1414
app:cardUseCompatPadding="false"
1515
app:cardPreventCornerOverlap="true">
1616

@@ -60,37 +60,38 @@
6060
android:id="@+id/ad_body"
6161
android:layout_width="0dp"
6262
android:layout_height="wrap_content"
63-
android:layout_marginTop="4dp"
6463
android:ellipsize="end"
6564
android:maxLines="2"
6665
android:textAppearance="@style/TextAppearance.Material3.BodySmall"
67-
app:layout_constraintTop_toBottomOf="@id/ad_headline"
6866
app:layout_constraintStart_toStartOf="@id/ad_headline"
69-
app:layout_constraintEnd_toEndOf="@id/ad_headline" />
67+
app:layout_constraintEnd_toEndOf="@id/ad_headline"
68+
app:layout_constraintTop_toBottomOf="@id/ad_headline" />
7069

7170
<me.zhanghai.android.materialratingbar.MaterialRatingBar
7271
android:id="@+id/ad_stars"
73-
style="@style/Widget.MaterialRatingBar.RatingBar"
72+
style="@style/Widget.MaterialRatingBar.RatingBar.Small"
7473
android:layout_width="wrap_content"
7574
android:layout_height="wrap_content"
7675
android:isIndicator="true"
7776
android:numStars="5"
7877
android:stepSize="0.5"
79-
android:layout_marginTop="8dp"
80-
app:layout_constraintTop_toBottomOf="@id/ad_body"
78+
app:layout_constraintBottom_toBottomOf="parent"
79+
app:layout_constraintEnd_toStartOf="@id/ad_call_to_action"
8180
app:layout_constraintStart_toStartOf="@id/ad_headline"
82-
app:layout_constraintBottom_toBottomOf="parent" />
81+
app:layout_constraintTop_toBottomOf="@id/ad_body" />
8382

8483
<com.google.android.material.button.MaterialButton
8584
android:id="@+id/ad_call_to_action"
8685
android:layout_width="wrap_content"
8786
android:layout_height="40dp"
8887
android:minWidth="88dp"
89-
android:insetTop="0dp"
90-
android:insetBottom="0dp"
9188
android:layout_marginStart="12dp"
92-
app:layout_constraintBaseline_toBaselineOf="@id/ad_stars"
93-
app:layout_constraintEnd_toEndOf="parent" />
89+
android:layout_marginTop="8dp"
90+
android:paddingHorizontal="12dp"
91+
app:layout_constraintEnd_toEndOf="parent"
92+
app:layout_constraintStart_toEndOf="@id/ad_stars"
93+
app:layout_constraintTop_toBottomOf="@id/ad_body"
94+
app:layout_constraintHorizontal_chainStyle="packed" />
9495

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
<com.d4rk.androidtutorials.java.ads.views.NativeAdBannerView
5757
android:id="@+id/ad_view"
5858
android:layout_width="match_parent"
59-
android:layout_height="match_parent"
59+
android:layout_height="wrap_content"
6060
app:nativeAdLayout="@layout/bottom_app_bar_native_ad" />
6161
</FrameLayout>
6262

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
style="@style/Widget.Material3.Button.TextButton"
5757
android:layout_width="wrap_content"
5858
android:layout_height="wrap_content"
59-
android:minWidth="64dp"
60-
android:minHeight="36dp"
59+
android:minWidth="88dp"
60+
android:minHeight="40dp"
6161
android:layout_marginStart="8dp" />
6262
</LinearLayout>
6363
</LinearLayout>

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
<com.google.android.material.card.MaterialCardView
1414
android:id="@+id/card_view_about"
1515
style="@style/Widget.Material3.CardView.Elevated"
16+
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.CardViewTopRounded"
1617
android:layout_width="match_parent"
1718
android:layout_height="wrap_content"
18-
android:layout_margin="24dp"
19-
app:cardCornerRadius="24dp"
19+
android:layout_marginHorizontal="24dp"
20+
android:layout_marginTop="24dp"
2021
app:layout_constraintTop_toTopOf="parent">
2122

2223
<androidx.constraintlayout.widget.ConstraintLayout
@@ -172,7 +173,7 @@
172173
android:id="@+id/ad_view"
173174
android:layout_width="match_parent"
174175
android:layout_height="wrap_content"
175-
android:layout_marginTop="16dp"
176+
android:layout_marginTop="2dp"
176177
app:layout_constraintTop_toBottomOf="@id/card_view_about"
177178
app:nativeAdLayout="@layout/about_native_ad" />
178179

0 commit comments

Comments
 (0)