[英]How do I make sure my webview can scale with devices?
我正試圖使我的網絡視圖位於我的Google Ad Mob廣告上方。 但是,除非我以編程方式嘗試調整高度,否則Web視圖始終覆蓋整個屏幕。 我嘗試將網絡視圖的高度設置為屏幕的高度減去我的廣告高度,但這似乎不能在所有設備上都能正常工作。 如果我想讓廣告位於網頁視圖下方,應該將其網頁視圖的高度設置為多少?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/linearLayout">
<WebView
android:id="@+id/webView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="320dip"
android:layout_height="50dip"
ads:adUnitId="/serviceid/myadtagishere"
ads:adSize="BANNER"
android:layout_below="@+id/webView1"/>
</RelativeLayout>
嘗試這個 :
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="320dip"
android:layout_height="50dip"
ads:adUnitId="/serviceid/myadtagishere"
ads:adSize="BANNER"
android:layout_alignParentBottom="true"/>
添加視圖應在Web視圖和全屏Web視圖上方。
我能夠使用線性布局解決此問題。 這似乎是使google ad mob廣告顯示在網絡視圖下方的最簡單,最有效的方法。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/linearLayout"
android:orientation="vertical">
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="50dip"
ads:adUnitId="/5773/sci.app.hoosierscoop"
ads:adSize="BANNER"/>
</LinearLayout>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.