3
我的目標是讓admob橫幅站在屏幕的底部,就像這張照片一樣:http://goo.gl/3POR1n但我不知道如何做橫幅坐在屏幕上,因爲我設置了更高的佈局。adMob |擴展橫幅大小?
LogCat說:沒有足夠的空間來顯示廣告。需要320x50的DP,但只有288x135 DP。
如何擴展我的空間以及如何在底部設置橫幅?
我的佈局XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="eu.gabrielatanasov.demoViewer.Home_activity" >
<ImageView
android:id="@+id/img_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/img_logo"
<Button
android:id="@+id/btn_subscription"
style="@style/button"
android:layout_marginTop="1dp"
android:text="@string/btn_subscription" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/adMob_ID" >
</com.google.android.gms.ads.AdView>
</LinearLayout>
</LinearLayout>
我dimens.xml:
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
我的活動:
package eu.gabrielatanasov.demoViewer;
import com.google.android.gms.ads.*;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Vibrator;
import android.view.View;
import android.view.Window;
import android.widget.Button;
public class Home_activity extends Activity {
Button btn_subscription;
AdView adView;
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
overridePendingTransition(R.anim.slide_in, R.anim.slide_out);
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_home);
adView = (AdView) this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
btn_subscription = (Button) findViewById(R.id.btn_subscription);
btn_subscription.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
vibrateButton(v);
}
});
}
public void vibrateButton(View v) {
buttonVibrate = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
buttonVibrate.vibrate(30);
}
}