Android 隐藏google广告会改变应用程序的布局

Android 隐藏google广告会改变应用程序的布局,android,android-layout,Android,Android Layout,我面临的问题,而我给谷歌广告的看法。走了,而没有互联网连接。当互联网连接处于活动状态时,这是一个完美的图像。 但当没有互联网连接时,我想上一个“下一步”按钮会转到顶部,因为它会失去参考 怎么办。我试着看。看不见,但它占据了底部的空白 当没有internet连接时,我希望将上一个“下一步”按钮置于底部 我的布局文件 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://sche

我面临的问题,而我给谷歌广告的看法。走了,而没有互联网连接。当互联网连接处于活动状态时,这是一个完美的图像。

但当没有互联网连接时,我想上一个“下一步”按钮会转到顶部,因为它会失去参考

怎么办。我试着看。看不见,但它占据了底部的空白

当没有internet连接时,我希望将上一个“下一步”按钮置于底部

我的布局文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/adView"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" />

    <TextView
        android:id="@+id/txtAd"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:background="#000"
        android:gravity="center"
        android:text="Advertisement"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#fff"
        android:visibility="gone" />

    <RelativeLayout
        android:id="@+id/RelativeLayout2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/navigation" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:src="@drawable/share" />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:src="@drawable/save" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:text="Birthday Cards"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="#fff"
            android:textSize="18sp" />
    </RelativeLayout>

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

    <LinearLayout
        android:id="@+id/ll1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/adView"
        android:layout_alignParentLeft="true"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/button4"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/ic_action_previous_item" />

            <Button
                android:id="@+id/button1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="2"
                android:text="set as Wallpaper" />

            <Button
                android:id="@+id/button3"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/ic_action_next_item" />
        </LinearLayout>
    </LinearLayout>

</RelativeLayout>


请帮助我解决问题。

请改用View.GONE。这将确保在安排事情时忽略它


另外,android:orientation不是有效的RelativeLayout属性,将被忽略。

使用View.GONE。这将确保在安排事情时忽略它


另外,android:orientation不是有效的RelativeLayout属性,将被忽略。

使用View.GONE。这将确保在安排事情时忽略它


另外,android:orientation不是有效的RelativeLayout属性,将被忽略。

使用View.GONE。这将确保在安排事情时忽略它


另一方面,android:orientation不是有效的RelativeLayout属性,将被忽略。

您使用的是
RelativeLayout
,并且您的一些元素(例如带有
id=“@+id/ll1”
的线性布局)是相对于您的
AdView
android:layout_over=“@+id/AdView”
)放置的

尝试打破此关系或使用
LinearLayout
作为根布局来解决问题

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

<RelativeLayout
        android:id="@+id/RelativeLayout2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/navigation" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:src="@drawable/share" />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:src="@drawable/save" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:text="Birthday Cards"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="#fff"
            android:textSize="18sp" />
    </RelativeLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:weight="1"
        android:layout_above="@+id/adView"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" />

    <LinearLayout
        android:id="@+id/ll1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/adView"
        android:layout_alignParentLeft="true"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/button4"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/ic_action_previous_item" />

            <Button
                android:id="@+id/button1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="2"
                android:text="set as Wallpaper" />

            <Button
                android:id="@+id/button3"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/ic_action_next_item" />
        </LinearLayout>
    </LinearLayout>
    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        ads:adSize="BANNER"
        ads:adUnitId="@string/ad_unit_id" >
    </com.google.android.gms.ads.AdView>

</LinearLayout >

您正在使用
RelativeLayout
,并且您的一些元素(例如带有
id=“@+id/ll1”
的线性布局)相对于您的
AdView
android:layout_上方=“@+id/AdView”
)放置

尝试打破此关系或使用
LinearLayout
作为根布局来解决问题

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

<RelativeLayout
        android:id="@+id/RelativeLayout2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/navigation" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:src="@drawable/share" />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:src="@drawable/save" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:text="Birthday Cards"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="#fff"
            android:textSize="18sp" />
    </RelativeLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:weight="1"
        android:layout_above="@+id/adView"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" />

    <LinearLayout
        android:id="@+id/ll1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/adView"
        android:layout_alignParentLeft="true"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/button4"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/ic_action_previous_item" />

            <Button
                android:id="@+id/button1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="2"
                android:text="set as Wallpaper" />

            <Button
                android:id="@+id/button3"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/ic_action_next_item" />
        </LinearLayout>
    </LinearLayout>
    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        ads:adSize="BANNER"
        ads:adUnitId="@string/ad_unit_id" >
    </com.google.android.gms.ads.AdView>

</LinearLayout >

您正在使用
RelativeLayout
,并且您的一些元素(例如带有
id=“@+id/ll1”
的线性布局)相对于您的
AdView
android:layout_上方=“@+id/AdView”
)放置

尝试打破此关系或使用
LinearLayout
作为根布局来解决问题

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

<RelativeLayout
        android:id="@+id/RelativeLayout2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/navigation" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:src="@drawable/share" />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:src="@drawable/save" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:text="Birthday Cards"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="#fff"
            android:textSize="18sp" />
    </RelativeLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:weight="1"
        android:layout_above="@+id/adView"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" />

    <LinearLayout
        android:id="@+id/ll1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/adView"
        android:layout_alignParentLeft="true"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/button4"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/ic_action_previous_item" />

            <Button
                android:id="@+id/button1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="2"
                android:text="set as Wallpaper" />

            <Button
                android:id="@+id/button3"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/ic_action_next_item" />
        </LinearLayout>
    </LinearLayout>
    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        ads:adSize="BANNER"
        ads:adUnitId="@string/ad_unit_id" >
    </com.google.android.gms.ads.AdView>

</LinearLayout >

您正在使用
RelativeLayout
,并且您的一些元素(例如带有
id=“@+id/ll1”
的线性布局)相对于您的
AdView
android:layout_上方=“@+id/AdView”
)放置

尝试打破此关系或使用
LinearLayout
作为根布局来解决问题

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

<RelativeLayout
        android:id="@+id/RelativeLayout2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/navigation" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:src="@drawable/share" />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:src="@drawable/save" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:text="Birthday Cards"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="#fff"
            android:textSize="18sp" />
    </RelativeLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:weight="1"
        android:layout_above="@+id/adView"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" />

    <LinearLayout
        android:id="@+id/ll1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/adView"
        android:layout_alignParentLeft="true"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/button4"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/ic_action_previous_item" />

            <Button
                android:id="@+id/button1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="2"
                android:text="set as Wallpaper" />

            <Button
                android:id="@+id/button3"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/ic_action_next_item" />
        </LinearLayout>
    </LinearLayout>
    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        ads:adSize="BANNER"
        ads:adUnitId="@string/ad_unit_id" >
    </com.google.android.gms.ads.AdView>

</LinearLayout >

android:layout\u alignWithParentIfMissing=“true”
添加到id为ll1的
线性布局应该可以工作

结果:

那么AlignizedParentIfMissing做什么呢?让我们引用一下:

如果设置为true,则在定位时父对象将用作定位 找不到layout_-toLeftOf、layout_-toRightOf等的


在id为ll1的
线性布局中添加
android:layout\u alignWithParentIfMissing=“true”
应该可以

结果:

那么AlignizedParentIfMissing做什么呢?让我们引用一下:

如果设置为true,则在定位时父对象将用作定位 找不到layout_-toLeftOf、layout_-toRightOf等的


在id为ll1的
线性布局中添加
android:layout\u alignWithParentIfMissing=“true”
应该可以

结果:

那么AlignizedParentIfMissing做什么呢?让我们引用一下:

如果设置为true,则在定位时父对象将用作定位 找不到layout_-toLeftOf、layout_-toRightOf等的


在id为ll1的
线性布局中添加
android:layout\u alignWithParentIfMissing=“true”
应该可以

结果:

那么AlignizedParentIfMissing做什么呢?让我们引用一下:

如果设置为true,则在定位时父对象将用作定位 找不到layout_-toLeftOf、layout_-toRightOf等的


你可以改变xml作为你的想法。不知道如何做到这一点。你将不得不使用垂直线性布局作为根。页眉布局、viewpager、页脚布局和adview将是父视图的子视图。若要为您的viewpager提供动态高度,请将高度设置为0,重量设置为1。未获取请放置一些示例教程链接或代码链接。您是否可以将xml更改为您的想法。不知道如何执行此操作。您必须使用垂直线性布局作为根。页眉布局、viewpager、页脚布局和adview将是父视图的子视图。若要为您的viewpager提供动态高度,请将高度设置为0,重量设置为1。未获取请放置一些示例教程链接或代码链接。您是否可以将xml更改为您的想法。不知道如何执行此操作。您必须使用垂直线性布局作为根。页眉布局、viewpager、页脚布局和adview将是父视图的子视图。若要为您的viewpager提供动态高度,请将高度设置为0,重量设置为1。未获取请放置一些示例教程链接或代码链接。您是否可以将xml更改为您的想法。不知道如何执行此操作。您必须使用垂直线性布局作为根。你的标题布局,vi