【问题标题】:Add a textview in java在java中添加一个textview
【发布时间】:2018-12-18 15:03:16
【问题描述】:

我在主要活动中有这段代码:

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 的政策,是使用 textview 将应用程序与横幅分开,就像它在图像中一样,怎么做?谢谢

【问题讨论】:

    标签: android layout textview


    【解决方案1】:

    使用

    <com.is.cut.App
        ...
        android:layout_above="@+id/adView"
        />
    

    【讨论】:

    • 不工作。我认为只要改变java代码就可以了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-25
    相关资源
    最近更新 更多