I have one fragment layout xml with RelativeLayout
containing AdView
with attribute android:layout_alignParentBottom="true"
but it is not getting aligned at bottom.
I also have another layout xml where this code is working. Please see two files below.
fragment_info:(Here AdView
not gets aligned to bottom)
<?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:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/refreshIndicator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="@+id/blogInfoWebView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.v4.widget.SwipeRefreshLayout>
<com.google.android.gms.ads.AdView
android:id="@+id/adViewBlogInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/blog_info_ad_unit" />
</RelativeLayout>
fragment_search:(Here AdView
get aligned to bottom)
<?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:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- Some code -->
</LinearLayout>
<include layout="@layout/fragment_post_list_web_view" />
</LinearLayout>
<com.google.android.gms.ads.AdView
android:id="@+id/adViewSearchList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/search_list_ad_unit" />
</RelativeLayout>
Check this Out with Linear Layout
<?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:layout_width="match_parent"
android:orientation="vertical"
android:gravity="center"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/refreshIndicator"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp">
<WebView
android:id="@+id/blogInfoWebView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.v4.widget.SwipeRefreshLayout>
<com.google.android.gms.ads.AdView
android:id="@+id/adViewBlogInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="@string/blog_info_ad_unit" />
</LinearLayout>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.