本文整理汇总了Java中com.google.android.gms.ads.NativeExpressAdView.setLayoutParams方法的典型用法代码示例。如果您正苦于以下问题:Java NativeExpressAdView.setLayoutParams方法的具体用法?Java NativeExpressAdView.setLayoutParams怎么用?Java NativeExpressAdView.setLayoutParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.ads.NativeExpressAdView
的用法示例。
在下文中一共展示了NativeExpressAdView.setLayoutParams方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getExpressAdView
import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
public static NativeExpressAdView getExpressAdView(Context context, ExpressAdPreset expressAdPreset) {
NativeExpressAdView adView = new NativeExpressAdView(context);
AdSize adSize = expressAdPreset.getAdSize();
adView.setAdSize(adSize);
adView.setAdUnitId(expressAdPreset.getAdUnitId());
adView.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
adSize.getHeightInPixels(context)));
//set video options
if(expressAdPreset.getVideoOptions() != null)
adView.setVideoOptions(expressAdPreset.getVideoOptions());
return adView;
}
示例2: AdNativeExpress
import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
public AdNativeExpress(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
LayoutInflater.from(context).inflate(R.layout.ad_native_express_view, this);
mNativeAdLayout = (FrameLayout) findViewById(R.id.ad_layout);
mProgress = findViewById(R.id.progress);
mAdText = findViewById(R.id.ad_text);
mGHImage = (AppCompatImageView) findViewById(R.id.gh_image);
findViewById(R.id.remove_ad).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ViewUtils.dialogDonate(v.getContext()).show();
}
});
mNativeExpressAdView = new NativeExpressAdView(context);
mNativeExpressAdView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
mNativeExpressAdView.setAdUnitId(getContext().getString(Utils.DARK_THEME ?
R.string.native_express_id_dark : R.string.native_express_id_light));
mNativeExpressAdView.setAdListener(new AdListener() {
@Override
public void onAdFailedToLoad(int i) {
super.onAdFailedToLoad(i);
mNativeLoading = false;
mNativeLoaded = false;
mNativeFailedLoading = true;
loadGHAd();
}
@Override
public void onAdLoaded() {
super.onAdLoaded();
mNativeLoaded = true;
mNativeLoading = false;
mNativeFailedLoading = false;
mProgress.setVisibility(GONE);
mNativeAdLayout.addView(mNativeExpressAdView);
}
});
}