Align AdView (AdMob) to bottom of screen with WebView on Android Layout
The default screen of my app shows a ListView. When the user selects an entry a new Activity is displayed with a Title (TextView), some information gained from xml (WebView).
I want to place an Ad aligned to the bottom of this second Activity.
My layout currently is this:
<LinearLayout android:id="@+id/info" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" style="@style/info">
<TextView android:id=开发者_如何学Python"@+id/title" style="@style/title" />
<WebView android:id="@+id/info" style="@style/info" />
</LinearLayout>
This works perfectly, but I can't get the Ad to always be at the bottom.
I've tried RelativeLayout, but no matter what, I always get the same results!
If the HTML shown in the WebView is short enough for the AdView to be displayed (but not at bottom, underneath WebView) or its too long and the AdView is not shown at all!
I want the AdView always visible always, even if the WebView scrolls!
Hope this makes sense!
Neil
PS: I'll continue to look for answers and update if I find one....
Figured out a way to solve this, but is it the best way??
This is how I did it:
<LinearLayout android:id="@+id/linearlayout" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:neildeadman="http://schemas.android.com/apk/res/com.neildeadman.android" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" style="@style/Info">
<LinearLayout android:id="@+id/info" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" style="@style/info">
<TextView android:id="@+id/title" style="@style/title" />
<WebView android:id="@+id/info" style="@style/info" />
</LinearLayout>
</LinearLayout>
The "layout_weight" attributes allowed me to force the inner LinearLayout to fill the remaining gap left by the add, which then contained my layout from above!
Works lovely....
精彩评论