Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Admob和ViewPager_Android_Android Viewpager_Admob - Fatal编程技术网

Android Admob和ViewPager

Android Admob和ViewPager,android,android-viewpager,admob,Android,Android Viewpager,Admob,我有以下xml代码,希望在ViewPager中添加AdMob。 我想做的结构是: 如何在应用程序底部添加AdMob?有人能帮我吗 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_p

我有以下xml代码,希望在ViewPager中添加AdMob。 我想做的结构是: 如何在应用程序底部添加AdMob?有人能帮我吗

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff"
android:orientation="vertical" >

<RelativeLayout
    android:id="@+id/header"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:background="@drawable/head" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:gravity="center_vertical"
        android:paddingLeft="30dp"
        android:text="Menú"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/openmenu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:background="@drawable/ic_action_overflow"
        android:clickable="true"
        android:contentDescription="Desc"
        android:visibility="visible" />

    <TextView
        android:id="@+id/refresh"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:background="@drawable/ic_action_refresh"
        android:clickable="true"
        android:contentDescription="Desc"
        android:visibility="visible" />
</RelativeLayout>

<!-- ADMOB -->
<LinearLayout
          android:id="@+id/adMob"
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="match_parent"/>

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <android.support.v4.view.ViewPager
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <android.support.v4.view.PagerTabStrip
            android:id="@+id/pagertabstrip"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="top"
            android:background="#1c1d22"
            android:paddingBottom="4dp"
            android:paddingTop="4dp"
            android:textColor="#fff" />
    </android.support.v4.view.ViewPager>

    <LinearLayout
        android:id="@+id/drawer"
        android:layout_width="240dp"
        android:layout_height="fill_parent"
        android:layout_gravity="left"
        android:background="#313131"
        android:orientation="vertical" >

        <ScrollView
            android:id="@+id/ScrollView01"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fillViewport="true"
            android:scrollbars="none" >

            <RelativeLayout
                android:layout_width="240dp"
                android:layout_height="fill_parent"
                android:background="#313131"
                android:orientation="vertical" >

                <Button
                    android:id="@+id/username"
                    android:layout_width="240dp"
                    android:layout_height="wrap_content"
                    android:background="@drawable/asidebck"
                    android:drawableLeft="@drawable/useraside"
                    android:gravity="left"
                    android:padding="15dp"
                    android:shadowColor="#000000"
                    android:shadowDx="0.3"
                    android:shadowDy="0"
                    android:shadowRadius="0.3"
                    android:text="Cargando..."
                    android:textColor="#fff" />

                <Button
                    android:id="@+id/title"
                    android:layout_width="240dp"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/username"
                    android:background="@drawable/asidet"
                    android:padding="15dp"
                    android:singleLine="true"
                    android:text="Mi cuenta"
                    android:textColor="#fff" />

                <Button
                    android:id="@+id/changecity"
                    android:layout_width="240dp"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/title"
                    android:background="@drawable/asidebck"
                    android:drawableLeft="@drawable/dealaside"
                    android:gravity="left|center_vertical"
                    android:padding="15dp"
                    android:singleLine="true"
                    android:text="Cambiar ciudad"
                    android:textColor="#fff" />

                <Button
                    android:id="@+id/logout"
                    android:layout_width="240dp"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/changecity"
                    android:background="@drawable/asidebck"
                    android:drawableLeft="@drawable/logoutaside"
                    android:gravity="left|center_vertical"
                    android:padding="15dp"
                    android:singleLine="true"
                    android:text="Cerrar sesión"
                    android:textColor="#fff" />

                <Button
                    android:id="@+id/title2"
                    android:layout_width="240dp"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/logout"
                    android:background="@drawable/asidet"
                    android:padding="15dp"
                    android:singleLine="true"
                    android:text="Ayuda y soporte"
                    android:textColor="#fff" />

                <Button
                    android:id="@+id/btn1"
                    android:layout_width="240dp"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/title2"
                    android:background="@drawable/asidebck"
                    android:drawableLeft="@drawable/helpaside"
                    android:gravity="left|center_vertical"
                    android:padding="15dp"
                    android:singleLine="true"
                    android:text="Reactivar ayuda"
                    android:textColor="#fff" />

                <Button
                    android:id="@+id/btn2"
                    android:layout_width="240dp"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/btn1"
                    android:background="@drawable/asidebck"
                    android:drawableLeft="@drawable/thumbs"
                    android:gravity="left|center_vertical"
                    android:padding="15dp"
                    android:singleLine="true"
                    android:text="Ayúdanos a mejorar"
                    android:textColor="#fff" />

                <Button
                    android:id="@+id/btn3"
                    android:layout_width="240dp"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/btn2"
                    android:background="@drawable/asidebck"
                    android:drawableLeft="@drawable/suggaside"
                    android:gravity="left|center_vertical"
                    android:padding="15dp"
                    android:singleLine="true"
                    android:text="Sugerencias"
                    android:textColor="#fff" />

                <Button
                    android:id="@+id/btn4"
                    android:layout_width="240dp"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/btn3"
                    android:background="@drawable/asidebck"
                    android:drawableLeft="@drawable/contactaside"
                    android:gravity="left|center_vertical"
                    android:padding="15dp"
                    android:singleLine="true"
                    android:text="Contacto"
                    android:textColor="#fff" />
            </RelativeLayout>
        </ScrollView>
    </LinearLayout>
</android.support.v4.widget.DrawerLayout>

因为您使用的是线性布局,所以只需将其作为您的布局中的最后一个元素即可code@Ayoub如果我把它放下,它就不起作用了。不显示广告块。我认为错误在于ViewPager中的heights您使用的match_parent太多,这样只有scrollview中的元素才可见,请尝试篡改这些高度,看看您能做些什么。