当前位置: 首页>>代码示例>>Java>>正文


Java AdView.setLayoutParams方法代码示例

本文整理汇总了Java中com.google.android.gms.ads.AdView.setLayoutParams方法的典型用法代码示例。如果您正苦于以下问题:Java AdView.setLayoutParams方法的具体用法?Java AdView.setLayoutParams怎么用?Java AdView.setLayoutParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.ads.AdView的用法示例。


在下文中一共展示了AdView.setLayoutParams方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addAds

import com.google.android.gms.ads.AdView; //导入方法依赖的package包/类
private void addAds() {
    // add AdMob
    AdView adView = new AdView(this);
    adView.setAdUnitId(AD_UNIT_ID);
    adView.setAdSize(AdSize.SMART_BANNER);

    LinearLayout.LayoutParams adLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    adView.setLayoutParams(adLayoutParams);

    // 広告表示位置は画面下部
    LinearLayout layout = new LinearLayout(this);
    layout.addView(adView);
    layout.setGravity(Gravity.BOTTOM);

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    addContentView(layout, layoutParams);

    // load ad
    AdRequest adRequest = new AdRequest.Builder().build();
    adView.loadAd(adRequest);
}
 
开发者ID:tmurakam,项目名称:presentationtimer-android,代码行数:22,代码来源:PrefActivity.java

示例2: createAdView

import com.google.android.gms.ads.AdView; //导入方法依赖的package包/类
private AdView createAdView() {
    mAdView = new AdView(this);
    mAdView.setAdSize(AdSize.LARGE_BANNER);

    // setup "testing" banner type
    boolean isStoreBuild = BuildConfig.FLAVOR.equals("playstore") && BuildConfig.BUILD_TYPE.equals("release");
    String adUnitId = isStoreBuild ? AD_UNIT_ID : "ca-app-pub-3940256099942544/6300978111";

    mAdView.setAdUnitId(adUnitId);
    mAdView.setId(View.generateViewId()); // this is an arbitrary id, allows for relative positioning in createGameView()
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    params.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    mAdView.setLayoutParams(params);
    mAdView.setBackgroundColor(Color.BLACK);

    return mAdView;
}
 
开发者ID:tgobbens,项目名称:fluffybalance,代码行数:20,代码来源:AndroidLauncher.java

示例3: loadAd

import com.google.android.gms.ads.AdView; //导入方法依赖的package包/类
private void loadAd(View view) {
    //Init ad
    adView = new AdView(application);
    adView.setAdUnitId(ApiUtils.AD_UNIT_ID_MAIN);
    adView.setAdSize(AdSize.BANNER);

    //Init params
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
            RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    params.addRule(RelativeLayout.CENTER_HORIZONTAL);
    params.setMargins(0, 0, 0, 24);
    adView.setLayoutParams(params);

    //Add to
    RelativeLayout rootContainer = (RelativeLayout) view.findViewById(R.id.rootContainer);
    rootContainer.addView(adView);

    AdRequest adRequest = new AdRequest.Builder().build();

    if (!DebugConfig.isDebug)
        adView.loadAd(adRequest);
}
 
开发者ID:almiso,项目名称:CollageApp,代码行数:24,代码来源:FragmentMain.java

示例4: loadAd

import com.google.android.gms.ads.AdView; //导入方法依赖的package包/类
private void loadAd(View view) {
    //Init ad
    adView = new AdView(application);
    adView.setAdUnitId(ApiUtils.AD_UNIT_ID_SEARCH_USER);
    adView.setAdSize(AdSize.BANNER);

    //Init params
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
            RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    params.addRule(RelativeLayout.CENTER_HORIZONTAL);
    params.setMargins(0, 0, 0, 24);
    adView.setLayoutParams(params);

    //Add to container
    RelativeLayout rootContainer = (RelativeLayout) view.findViewById(R.id.rootContainer);
    rootContainer.addView(adView);

    //Add request
    AdRequest adRequest = new AdRequest.Builder().build();

    if (!DebugConfig.isDebug)
        adView.loadAd(adRequest);
}
 
开发者ID:almiso,项目名称:CollageApp,代码行数:25,代码来源:FragmentSearchUserByNick.java

示例5: loadAd

import com.google.android.gms.ads.AdView; //导入方法依赖的package包/类
private void loadAd(View view) {
    //Init ad
    adView = new AdView(application);
    adView.setAdUnitId(ApiUtils.AD_UNIT_ID_USER_PROFILE);
    adView.setAdSize(AdSize.BANNER);

    //Init params
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
            RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    params.addRule(RelativeLayout.CENTER_HORIZONTAL);
    params.setMargins(0, 0, 0, 24);
    adView.setLayoutParams(params);

    //Add to container
    RelativeLayout rootContainer = (RelativeLayout) view.findViewById(R.id.rootContainer);
    rootContainer.addView(adView);

    //Add request
    AdRequest adRequest = new AdRequest.Builder().build();

    if (!DebugConfig.isDebug)
        adView.loadAd(adRequest);
}
 
开发者ID:almiso,项目名称:CollageApp,代码行数:25,代码来源:FragmentUserProfile.java

示例6: onCreateView

import com.google.android.gms.ads.AdView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    
	//Create the AdView fragment container layout
    View v = inflater.inflate(R.layout.fragment_ad, container, false);
    
    //Generate the AdView and configure it
    mAdView = new AdView(v.getContext());
    mAdView.setVisibility(View.GONE);
    RelativeLayout.LayoutParams mAdViewLayout = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    mAdView.setLayoutParams(mAdViewLayout);
    //...set the Ads info
    mAdView.setAdSize(adSize);
    mAdView.setAdUnitId(adUnitId);
    
    //Add the AdView to the fragment container layout :)
    ((RelativeLayout)v).addView(mAdView);
    
    return v;
}
 
开发者ID:javocsoft,项目名称:javocsoft-toolbox,代码行数:22,代码来源:AdFragment.java

示例7: createadmob

import com.google.android.gms.ads.AdView; //导入方法依赖的package包/类
private AdView createadmob() {
    AdView mAdView = new AdView(this);
    mAdView.setAdSize(AdSize.MEDIUM_RECTANGLE);
    mAdView.setAdUnitId("ca-app-pub-3940256099942544/6300978111");
    mAdView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    // Create an ad request.
    AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
    if (admob_test_mode)
        // Optionally populate the ad request builder.
        adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
    // Start loading the ad.
    mAdView.loadAd(adRequestBuilder.build());
    return mAdView;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:TestAdMobClassicActivity.java

示例8: createAdView

import com.google.android.gms.ads.AdView; //导入方法依赖的package包/类
private void createAdView() {
    adView = new AdView(this);
    adView.setAdSize(AdSize.SMART_BANNER);
    adView.setAdUnitId(AD_UNIT_ID);
    adView.setId(R.id.adsMobId); // this is an arbitrary id, allows for relative positioning in createGameView()
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    params.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    adView.setLayoutParams(params);
    adView.setBackgroundColor(Color.BLACK);
}
 
开发者ID:ZephyrVentum,项目名称:FlappySpinner,代码行数:12,代码来源:AndroidLauncher.java

示例9: createAdView

import com.google.android.gms.ads.AdView; //导入方法依赖的package包/类
private AdView createAdView() {
  adView = new AdView(this);
  adView.setAdSize(AdSize.SMART_BANNER);
  adView.setAdUnitId(AD_UNIT_ID);
  adView.setId(12345); // this is an arbitrary id, allows for relative positioning in createGameView()
  RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
  params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
  params.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
  adView.setLayoutParams(params);
  adView.setBackgroundColor(Color.BLACK);
  return adView;
}
 
开发者ID:Jocke101,项目名称:MathMemory,代码行数:13,代码来源:AndroidLauncher.java

示例10: createAdView

import com.google.android.gms.ads.AdView; //导入方法依赖的package包/类
private AdView createAdView() {
    AdView adView = new AdView(this);
    adView.setAdSize(AdSize.SMART_BANNER);
    adView.setAdUnitId(getString(R.string.ad_banner1));
    adView.setId(12345);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    params.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    adView.setLayoutParams(params);
    adView.setBackgroundColor(Color.BLACK);
    return adView;
}
 
开发者ID:mcprog,项目名称:ragnar,代码行数:13,代码来源:AndroidLauncher.java

示例11: createAdView

import com.google.android.gms.ads.AdView; //导入方法依赖的package包/类
private AdView createAdView() {
	adView = new AdView(this);
       adView.setAdSize(AdSize.SMART_BANNER);
       adView.setAdUnitId(SMALL_CODE);
       adView.setId(12345); // this is an arbitrary id, allows for relative positioning in createGameView()
       RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
       params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
       params.addRule(RelativeLayout.CENTER_HORIZONTAL);
       layout.setLayoutParams(params);
       adView.setLayoutParams(params);
       adView.setBackgroundColor(Color.TRANSPARENT);
       return adView;
}
 
开发者ID:costular,项目名称:crabox,代码行数:14,代码来源:AndroidLauncher.java

示例12: getView

import com.google.android.gms.ads.AdView; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if ((position % 5) == 2) {
        if (convertView instanceof AdView) {
            // Don’t instantiate new AdView, reuse old one
            return convertView;
        } else {
            // Create a new AdView
            AdView adView = new AdView(activity);
            adView.setAdUnitId(activity.getResources().getString(R.string.banner_ad_unit_id_test));
            adView.setAdSize(AdSize.BANNER);
            adView.loadAd(createAdRequest());
            adView.setAdListener(new LogAndToastAdListener(activity));

            // Convert the default layout parameters so that they play nice with
            // ListView.

            float density = activity.getResources().getDisplayMetrics().density;
            int height = Math.round(AdSize.BANNER.getHeight() * density);
            AbsListView.LayoutParams params = new AbsListView.LayoutParams(
                    AbsListView.LayoutParams.MATCH_PARENT,
                    height);

            adView.setLayoutParams(params);
            return adView;
        }
    } else {
        if (convertView instanceof AdView) {
            convertView = null;
        }
        // Offload displaying other items to the delegate
        return delegate.getView(position - ((position + 3) / 5),
                convertView, parent);
    }
}
 
开发者ID:pgodzin,项目名称:QuotesSocial,代码行数:36,代码来源:AdListAdapter.java

示例13: onCreate

import com.google.android.gms.ads.AdView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main_page);
	
	
	adView = new AdView(this);
	adView.setAdUnitId("ca-app-pub-4147454460675251/3837655321");
	adView.setAdSize(AdSize.BANNER);
	
	adView.setAdListener(adListener);
	
	RelativeLayout adLayout = (RelativeLayout)findViewById(R.id.main_page_adview_layout);
	adLayout.addView(adView);
	
	RelativeLayout.LayoutParams adViewlp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	adViewlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
	adViewlp.addRule(RelativeLayout.CENTER_HORIZONTAL);
	adView.setLayoutParams(adViewlp);

	
	AdRequest request = new AdRequest.Builder()
	.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
    .addTestDevice("04E14595EE84A505616E50A99B15252D")
    .build();
	
	
	adView.loadAd(request);
	
	System.out.println("---------------------- istestdevice: "+request.isTestDevice(this));

	
	mContext = this;
	
	DisplayMetrics dm = new DisplayMetrics();
	getWindowManager().getDefaultDisplay().getMetrics( dm );
	
	screenWidth = dm.widthPixels;
	screenHeight = dm.heightPixels;
	
	final TextView headerText = (TextView)findViewById(R.id.mainHeaderText);
	RelativeLayout.LayoutParams headerTextParams = (RelativeLayout.LayoutParams)headerText.getLayoutParams();
	headerTextParams.leftMargin = screenHeight/8;
	headerText.setLayoutParams(headerTextParams);
	headerText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, (float)screenHeight/35);
	headerText.setText("Face Recognition");
	headerText.setTextColor(Color.LTGRAY);
	headerText.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
	headerText.setTypeface(null, Typeface.BOLD);
	
	ImageView headerIcon = (ImageView)findViewById(R.id.mainHeaderIcon);
	RelativeLayout.LayoutParams iconLParams = new RelativeLayout.LayoutParams(screenHeight/11, screenHeight/11);
	iconLParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT | RelativeLayout.CENTER_VERTICAL);
	iconLParams.leftMargin = screenHeight/80;
	headerIcon.setLayoutParams(iconLParams);
	
	
	ListView listView = (ListView)findViewById(R.id.mainListView);
	ListAdapter listAdapter = new ListAdapter();
	listView.setAdapter(listAdapter);
	listView.setOnItemClickListener(itemClickListener);
	
	RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)listView.getLayoutParams();
	params.leftMargin = screenWidth/10;
	params.rightMargin = screenWidth/10;
	params.topMargin = screenHeight/12;
	listView.setLayoutParams(params);
	listView.setVerticalScrollBarEnabled(false);

}
 
开发者ID:yaylas,项目名称:AndroidFaceRecognizer,代码行数:71,代码来源:MainPageActivity.java


注:本文中的com.google.android.gms.ads.AdView.setLayoutParams方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。