android - alignParentBottom appears Offscreen in Fragment with Scroll View -
for wanting have adview in app comprised of fragment layouts, hope below helps you!
basically, trying place adview inside layout xml each fragment. caused adview either pushed off screen or not play nice relative layout commands (ex. alignparentbottom).
the solution move adview main activity layout outside of the coordinator layout used fragments. wrapped coordinator layout , adview in relative layout.
this allowed me control adview , present on each fragment pinned bottom of screen.
i have found when change background of scrollview, paints on adview. must place adview below scrollview in code. way, drawn after scrollview , therefore on top.
here edited code:
<?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:paddingleft="16dp" android:paddingright="16dp"> <!-- dummy item prevent edittextview receiving focus --> <linearlayout android:id="@+id/dummylayout" android:layout_width="0dp" android:layout_height="0dp" android:focusable="true" android:focusableintouchmode="true" android:orientation="horizontal" /> <!-- dummy item prevent edittextview receiving focus --> <linearlayout android:id="@+id/linearlayout1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparenttop="true" android:orientation="horizontal"> <textview android:id="@+id/textview1" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <textview android:id="@+id/textview2" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <edittext android:id="@+id/edittext1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="4" android:hint="@string/hint" android:nextfocusleft="@id/edittext1" android:nextfocusup="@id/edittext1" android:singleline="true"/> <textview android:id="@+id/textview3" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </linearlayout> <textview android:id="@+id/textview4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/linearlayout1"/> <button android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/textview4"/> <tablelayout android:id="@+id/tablelayout1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/button1" android:background="@color/coloraccent0" android:stretchcolumns="*"/> <scrollview android:id="@+id/scrollview" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/tablelayout1" android:layout_above="@+id/adview" android:background="@color/colorgray"> <tablelayout android:id="@+id/tablelayout2" android:layout_width="match_parent" android:layout_height="match_parent" android:stretchcolumns="*"/> </scrollview> <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_centerhorizontal="true" ads:adsize="banner" ads:adunitid="@string/banner_ad_unit_id"> </com.google.android.gms.ads.adview> </relativelayout>
Comments
Post a Comment