在Java中添加TextView

时间:2018-07-10 17:05:53

标签: android layout textview

主要活动中我有以下代码:

if (T.ISHORIZONTAL) {
        // if(T.DISPLAY_WIDTH<480)
        adView = new AdView(this);
        adView.setAdSize(AdSize.SMART_BANNER);
        adView.setAdUnitId(getResources().getString(
                R.string.banner_ad_unit_id));
        // else
        // adView = new AdView(this, AdSize., "a150a0ece652e81");
        app = new App(context, null);
        FrameLayout layout = new FrameLayout(this);
        FrameLayout.LayoutParams gameParams = new FrameLayout.LayoutParams(
                FrameLayout.LayoutParams.FILL_PARENT,
                FrameLayout.LayoutParams.FILL_PARENT);
        adsParams = new FrameLayout.LayoutParams(
                FrameLayout.LayoutParams.WRAP_CONTENT,
                FrameLayout.LayoutParams.WRAP_CONTENT,
                android.view.Gravity.BOTTOM | android.view.Gravity.CENTER);
        if (T.DISPLAY_WIDTH < 380) {
            adsParams.setMargins(-70, 0, -70, 0);
        }
        layout.addView(app, gameParams);
        layout.addView(adView, adsParams);
        AdRequest adRequest = new AdRequest.Builder().build();
        adView.loadAd(adRequest);
        setContentView(layout);
    } else {

        setContentView(R.layout.main_lay);
        app = (App) findViewById(R.id.gameBoard1);
        adView = (AdView) findViewById(R.id.adView);

以及xml中的内容:

   <?xml version="1.0" encoding="utf-8"?>
   <RelativeLayout xmlns:ads="http://schemas.android.com/apk/res-auto"
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent" >

<com.is.cut.App
    android:id="@+id/gameBoard1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />

<com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    ads:adSize="BANNER"
    ads:adUnitId="@string/banner_ad_unit_id" >
</com.google.android.gms.ads.AdView>

banner

我的目标是遵守Admob的政策,就是使用文本视图将应用程序与横幅分开,就像图像中一样,怎么办?谢谢

1 个答案:

答案 0 :(得分:0)

使用

<action android:name="com.example.My Application.LAUNCH" />