Android Studio 1.0.2在linux機器上生成以下相對佈局。android studio相對佈局模板在展示admob廣告時出現問題
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<fragment
android:id="@+id/adFragment"
android:name="com.gatta.e.gatta.MainActivity$AdFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout="@layout/fragment_ad"
android:layout_alignParentBottom="true" />
<WebView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/webView"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_above="@+id/adFragment" />
</RelativeLayout>
AdMob廣告引發警告
a W/Ads﹕ Not enough space to show ad. Needs 320x50 dp, but only has 288x488 dp.
和廣告並未在縱向模式(顯示風景模式廣告)
當填充*相對佈局的屬性被刪除所顯示的警告不顯示,並顯示廣告。
是否刪除填充*屬性有任何缺點。如何在不刪除填充*屬性的情況下顯示廣告。
從相對佈局中刪除填充。 @ dimen/activity_horizontal_margin通常是16dp,16 * 2 = 32和320 - 32 = 288。 –