Android覆盖在屏幕底部

Android覆盖在屏幕底部,android,android-overlay,Android,Android Overlay,我想在我的应用程序中实现广告,但我想实现 覆盖视图上的广告,应用程序的主要内容应该是 前景和覆盖是主要内容的顶部,我想 在屏幕底部将屏幕整体对齐。请告诉我怎么做 我可以实现屏幕底部的覆盖???实现这一点的最简单方法是使用FrameLayout作为根视图。下面是一些代码来演示这一点。我还没有测试过这个特定的示例,但是它应该对AdView属性进行轻微修改 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/andro

我想在我的应用程序中实现广告,但我想实现 覆盖视图上的广告,应用程序的主要内容应该是 前景和覆盖是主要内容的顶部,我想 在屏幕底部将屏幕整体对齐。请告诉我怎么做
我可以实现屏幕底部的覆盖???

实现这一点的最简单方法是使用FrameLayout作为根视图。下面是一些代码来演示这一点。我还没有测试过这个特定的示例,但是它应该对AdView属性进行轻微修改

<FrameLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
    <LinearLayout
        android:id="@+id/main_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <!-- Your main layout code goes here -->
    </LinearLayout>
    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        ads:adUnitId="MY_AD_UNIT_ID"
        ads:adSize="BANNER"
        ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
        ads:loadAdOnCreate="true"/>
</FrameLayout>


注意AdView的layout_gravity属性;这就是它出现在屏幕底部的原因。

实现这一点的最简单方法是使用FrameLayout作为根视图。下面是一些代码来演示这一点。我还没有测试过这个特定的示例,但是它应该对AdView属性进行轻微修改

<FrameLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
    <LinearLayout
        android:id="@+id/main_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <!-- Your main layout code goes here -->
    </LinearLayout>
    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        ads:adUnitId="MY_AD_UNIT_ID"
        ads:adSize="BANNER"
        ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
        ads:loadAdOnCreate="true"/>
</FrameLayout>


注意AdView的layout_gravity属性;这就是它出现在屏幕底部的原因。

您现在尝试了什么uptill?请把你试过的代码贴出来。我什么都没做。我必须开始。如果我想让它更清楚,那么我想做的是在屏幕底部覆盖。如果你有一些代码,那么让我知道你现在尝试了什么?请把你试过的代码贴出来。我什么都没做。我必须开始。如果我想让它更清楚,那么我想做的是在屏幕底部覆盖。如果你有一些代码,那么让我知道我不知道你到底是什么意思。id=main_布局的线性布局将覆盖整个屏幕,广告将显示在main_布局顶部的底部。Sanket的回答也提供了一种设置覆盖的有效方法,但我总是发现对于这样一个简单的案例,这个方法更容易理解。我不确定你的确切意思。id=main_布局的线性布局将覆盖整个屏幕,广告将显示在main_布局顶部的底部。Sanket的回答也提供了一种设置覆盖的有效方法,但我总是发现对于这样一个简单的情况,这一方法更容易理解。