Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ab0dc7b

Browse files
Merge pull request #261 from MihaiCristianCondrea/codex/fix-visibility-of-why-this-ad-icon
Add AdChoices icon to about banner ad
2 parents a7eb702 + 409cfc9 commit ab0dc7b

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

‎app/src/main/java/com/d4rk/androidtutorials/java/ads/managers/NativeAdLoader.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.google.android.gms.ads.AdLoader;
1818
import com.google.android.gms.ads.AdRequest;
1919
import com.google.android.gms.ads.LoadAdError;
20+
import com.google.android.gms.ads.nativead.AdChoicesView;
2021
import com.google.android.gms.ads.nativead.MediaView;
2122
import com.google.android.gms.ads.nativead.NativeAd;
2223
import com.google.android.gms.ads.nativead.NativeAdView;
@@ -84,6 +85,7 @@ private static void populateNativeAdView(@NonNull NativeAd nativeAd, @NonNull Na
8485
Button callToActionView = adView.findViewById(R.id.ad_call_to_action);
8586
ImageView iconView = adView.findViewById(R.id.ad_app_icon);
8687
TextView attributionView = adView.findViewById(R.id.ad_attribution);
88+
AdChoicesView adChoicesView = adView.findViewById(R.id.ad_choices);
8789

8890
if (mediaView != null) {
8991
adView.setMediaView(mediaView);
@@ -95,6 +97,9 @@ private static void populateNativeAdView(@NonNull NativeAd nativeAd, @NonNull Na
9597
adView.setIconView(iconView);
9698
}
9799
adView.setAdvertiserView(attributionView);
100+
if (adChoicesView != null) {
101+
adView.setAdChoicesView(adChoicesView);
102+
}
98103

99104
if (headlineView != null) {
100105
headlineView.setText(nativeAd.getHeadline());

‎app/src/main/res/layout/ad_about.xml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@
4343
android:layout_height="match_parent" />
4444
</com.google.android.material.card.MaterialCardView>
4545

46+
<com.google.android.gms.ads.nativead.AdChoicesView
47+
android:id="@+id/ad_choices"
48+
android:layout_width="wrap_content"
49+
android:layout_height="wrap_content"
50+
android:layout_marginTop="4dp"
51+
android:layout_marginEnd="4dp"
52+
app:layout_constraintEnd_toEndOf="parent"
53+
app:layout_constraintTop_toTopOf="parent" />
54+
4655
<com.google.android.material.textview.MaterialTextView
4756
android:id="@+id/ad_headline"
4857
android:layout_width="0dp"

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /