Reputation: 262
I have an AdMob Banner and it is showing up correctly but it is way too small. It's not fitting the width of the screen. This happens both on the emulator and the real devices. Can anyone help me solve this problem? XML CODE:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/usernameLab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Username:"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="35px" />
<EditText
android:id="@+id/usernameField"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName" />
<TextView
android:id="@+id/passwordLab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Password:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="35px" />
<EditText
android:id="@+id/passwordField"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textPassword" />
<Button
android:id="@+id/login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Login" />
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Remember me?" />
<CheckBox
android:id="@+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Parent Account?" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="124dp"
android:src="@drawable/cool" />
<LinearLayout
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="..."
ads:loadAdOnCreate="true"
/>
</LinearLayout>
</LinearLayout>
Upvotes: 1
Views: 4054
Reputation: 4534
Take a look at this:
https://developers.google.com/mobile-ads-sdk/docs/android/intermediate
In most cases the best approach is to use SMART_BANNER size and let Admod SDK take care of the banner size, just make sure of leaving at least 90 pixels height for the tallest banner.
Upvotes: 1
Reputation: 5459
According to the image you posted the ad is showing at 320 x 50 pixels and your overall resolution is 480 x 800. I'm going to assume that the pixel density is 1.0 (This would be an Abstracted LCD density of 160, a setting under your AVD device properties). This is an unusual density. The vast majority of phones have a pixel density of 1.5 (Abstracted LCD density of 240) resulting in a screen width of 320 dip, and with that setting it should render properly.
If you want to make sure that your ad always fills the width of the screen, there are two approaches. On Honeycomb and up (API Level 11+) you can use setScaleX() and setScaleY() to scale it. You'll have to get the screen width and scale it appropriately. For Gingerbread and earlier you'll have to figure out scaling. I don't know what options are available there. Scaling will result in some pixelation and generally people prefer to just center the ad rather than stretch it.
TL;DR: Most people will see it fine, you can center it or stretch it yourself
Upvotes: 1