开发者

Buttons above admob ad in android

开发者 https://www.devze.com 2023-03-13 21:18 出处:网络
I want to place my three buttons above the admob ad which is in a relativelayout. The ad is overlapping the buttons whereas I want the ad to display below the buttons.

I want to place my three buttons above the admob ad which is in a relativelayout. The ad is overlapping the buttons whereas I want the ad to display below the buttons.

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:background="#ffffff" android:id="@+id/puzzlelayout">

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true" android:layout_alignParentBottom="true"
        android:id="@+id/puzzlelayout1">

        <Button android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:id="@+id/btn3"
             android:background="@drawable/custom_quiz_button"></Button>

        <Button android:layout_width="wrap_content"
             android:layout_height="wrap_content"
            android:id="@+id/btn2" 
            android:layout_toRightOf="@+id/btn3" android:visibility="visible"
            a开发者_高级运维ndroid:background="@drawable/custom_quiz_button"></Button>

        <Button android:layout_width="wrap_content"
             android:layout_height="wrap_content"
            android:id="@+id/btn1" android:layout_toRightOf="@+id/btn2"
            android:background="@drawable/custom_quiz_button"></Button>

    </RelativeLayout>

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_below="@+id/puzzlelayout1" android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:id="@+id/linearLayout02" android:layout_alignParentBottom="true"
        >
    </RelativeLayout>
</RelativeLayout>


you could try something like (i took out the images to test it out):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:layout_centerInParent="true"
    android:id="@+id/puzzlelayout1">
    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:layout_above="@+id/linearLayout02">
        <Button android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:id="@+id/btn3"></Button>
        <Button android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:id="@+id/btn2"
            android:layout_toRightOf="@+id/btn3" android:visibility="visible"></Button>
        <Button android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:id="@+id/btn1"
            android:layout_toRightOf="@+id/btn2"></Button>
    </LinearLayout>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:id="@+id/linearLayout02" android:layout_alignParentBottom="true">
    </LinearLayout>
</RelativeLayout>


You have written android:layout_alignParentBottom="true" twice in two different Relative layout. just delete the first one. thats why both the linear layout were at the bottom of the scren

Try

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:background="#ffffff" android:id="@+id/puzzlelayout">

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true" 
        android:id="@+id/puzzlelayout1">

        <Button android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:id="@+id/btn3"
             android:background="@drawable/custom_quiz_button"></Button>

        <Button android:layout_width="wrap_content"
             android:layout_height="wrap_content"
            android:id="@+id/btn2" 
            android:layout_toRightOf="@+id/btn3" android:visibility="visible"
            android:background="@drawable/custom_quiz_button"></Button>

        <Button android:layout_width="wrap_content"
             android:layout_height="wrap_content"
            android:id="@+id/btn1" android:layout_toRightOf="@+id/btn2"
            android:background="@drawable/custom_quiz_button"></Button>

    </RelativeLayout>

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_below="@+id/puzzlelayout1" android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:id="@+id/linearLayout02" android:layout_alignParentBottom="true"
        >
    </RelativeLayout>
</RelativeLayout>

Thanks Deepak

0

精彩评论

暂无评论...
验证码 换一张
取 消