1
\$\begingroup\$

After trying to add a banner ad to my game, the rest of my games content has moved up! I have the following XML code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:id="@+id/layout"
    android:gravity="center"
    android:background="@drawable/blurbackground"

    xmlns:ads="http://schemas.android.com/apk/res-auto"

    >
    <Button
        android:id="@+id/levelone"

        android:text="Level One"
        android:textColor="#FFFFFF"
        android:textSize="30sp"
        android:onClick = "levelone"
        android:layout_width="270dp"
        android:layout_height="100dp"
        android:background="@drawable/buttonshape"
        android:shadowColor="#A8A8A8"
        android:shadowDx="0"
        android:shadowDy="0"
        android:shadowRadius="5"
        android:layout_above="@+id/leveltwo"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginBottom="64dp" />

    <Button
        android:id="@+id/leveltwo"

        android:text="Level Two (LOCKED)"
        android:textColor="#FFFFFF"
        android:textSize="30sp"
        android:onClick = "leveltwo"
        android:layout_width="270dp"
        android:layout_height="100dp"
        android:background="@drawable/buttonshape"
        android:shadowColor="#A8A8A8"
        android:shadowDx="0"
        android:shadowDy="0"
        android:shadowRadius="5"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginBottom="64dp" />


    <Button
        android:id="@+id/levelthree"

        android:text="Level Three (LOCKED)"
        android:textColor="#FFFFFF"
        android:textSize="30sp"
        android:onClick = "levelthree"
        android:layout_width="270dp"
        android:layout_height="100dp"
        android:background="@drawable/buttonshape"
        android:shadowColor="#A8A8A8"
        android:shadowDx="0"
        android:shadowDy="0"
        android:shadowRadius="5"
        android:layout_below="@+id/leveltwo"
        android:layout_alignLeft="@+id/leveltwo"
        android:layout_alignStart="@+id/leveltwo" />

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

</RelativeLayout>

here is buttonshape.xml in drawable:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
    <corners
        android:topLeftRadius="100dp"
        android:topRightRadius="100dp"
        android:bottomLeftRadius="100dp"
        android:bottomRightRadius="100dp"
        />
    <gradient
        android:angle="315"
        android:centerX="35%"
        android:centerColor="#5497A8"
        android:startColor="#5BE81E"
        android:endColor="#FF5EC4"
        android:type="linear"
        />
    <padding
        android:left="0dp"
        android:top="0dp"
        android:right="0dp"
        android:bottom="0dp"
        />
    <size
        android:width="250dp"
        android:height="100dp"
        />
    <stroke
        android:width="3dp"
        android:color="#878787"
        />
</shape>

but ever since I added my banner adview at the bottom, all three of my buttons have moved out of place, and the ad doesn't show in the layout editor.

How can I fix this, and re-center all three of my buttons again?

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.