Separate Admob Banner From Application Content With Border
I read on this Google support page that it is against policy to have ads overlap application content, and that ads should be separated from the content with a border. Currently, b
Solution 1:
You can use a LinearLayout instead of the FrameLayout, with orientation set to vertical, to make content flow one after the other, as opposed to one on top of the other.
<?xml version="1.0" encoding="utf-8"?><android.support.v4.widget.DrawerLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:ads="http://schemas.android.com/apk/res-auto"android:id="@+id/fragmentDrawerLayout"android:layout_width="match_parent"android:layout_height="match_parent"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"orientation="vertical"><!-- Main content --><RelativeLayoutandroid:id="@+id/fragmentDrawerContainer"android:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="100" /><!-- Banner ad --><com.google.android.gms.ads.AdViewandroid:id="@+id/adView"android:layout_width="wrap_content"android:layout_height="wrap_content"ads:adSize="SMART_BANNER"ads:adUnitId="@string/banner_ad_unit_id"/></LinearLayout><!-- Navigation drawer --><ListViewandroid:id="@+id/fragmentLeftDrawer"android:layout_width="200dp"android:layout_height="match_parent"android:layout_gravity="start"android:choiceMode="singleChoice"android:divider="@android:color/transparent"android:textStyle="bold"android:dividerHeight="0dp"/></android.support.v4.widget.DrawerLayout>
Using 0dp
for the layout height and a weight of 100
will tell the LinearLayout to calculate the size of the AdView first, then fill up the remaining space with the RelativeLayout.
(In this particular case, the weight could have been any non-zero value, because we didn't give any weight to the AdView.)
For more information on layout weights, you can checkout Mark Allison's tutorials on his StylingAndroid blog:
Post a Comment for "Separate Admob Banner From Application Content With Border"