Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MyActivity"
android:background="#ff000640">

<WebView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/webView"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"

    android:layout_alignParentTop="true"
    android:layout_above="@+id/adView"
   />

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

Why is it red? When I run the app the adview works just fine so I have no idea why it wouldn't be working. The red part also disappears for a short while once I run the app. when I change above to below it gives no error

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
227 views
Welcome To Ask or Share your Answers For Others

1 Answer

@+id/adView : the + sign means to generate a new id if it does not exist yet. I think it would be better to

<WebView ...
         android:layout_above="@id/adView"

meaning to refer to another component with id adView and as Krishnabhadra suggests, put the AdView declaration first.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...