- 需确保创建ATNativeAdView实例时传入的是Activity
- 华为提供"原生广告下载按钮控件"(参考华为原生广告下载按钮控件说明)提高应用下载类原生广告的下载转化效果。
Taku提供ATNativeMaterial#getAppDownloadButton()提供华为下载按钮控件接入,具体接入方式参考下方bindSelfRenderView示例代码。
public static void bindSelfRenderView(Context context, ATNativeMaterial adMaterial,
View selfRenderView, ATNativePrepareInfo nativePrepareInfo) {
......
// AppDownloadButton(Only Huawei Ads support)
View lastView = ((ViewGroup) selfRenderView).getChildAt(((ViewGroup) selfRenderView).getChildCount() - 1);
// Remove AppDownloadButton since last time added
if (lastView instanceof AppDownloadButton) {
((ViewGroup) selfRenderView).removeView(lastView);
}
//View appDownloadButton = adMaterial.getAppDownloadButton();
//v6.3.70或以上版本
View appDownloadButton = adMaterial.getCallToActionButton();
if (appDownloadButton != null) {
if (appDownloadButton instanceof AppDownloadButton) {
((AppDownloadButton) appDownloadButton).setTextSize(dip2px(context, 12));
appDownloadButton.setPadding(dip2px(context, 46),dip2px(context, 24),dip2px(context, 46),dip2px(context, 24));//调整按钮大小
}
ViewGroup.LayoutParams ctaParams = ctaView.getLayoutParams();
((ViewGroup) selfRenderView).addView(appDownloadButton, ctaParams);
appDownloadButton.setVisibility(View.VISIBLE);
ctaView.setVisibility(View.INVISIBLE);
}
}
注意:getAppDownloadButton()可能返回null,接入时需要进行判空处理;点击AppDownloadButton不会触发onAdClicked回调,但不会影响收益;