iam trying to place admob add at bnottom of my application ...for that i wrote the following code ....am getting entire application except adds...can u please help me
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
android:id="@+id/LinearLayout01"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/wp"
android:gravity="right"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:background="@color/black"
android:orientation="horizontal"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:src="@drawable/header"
android:id="@+id/ImageView01"
android:layout_height="wrap_content"></ImageView>
<TextView
android:layout_width="fill_parent"
android:textColor="@color/white"
android:text="Tip Calculator"
android:typeface="sans"
android:textSize="26sp"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:id="@+id/TextView07"></TextView>
</LinearLayout>
<AbsoluteLayout
android:id="@+id/widget0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/widget28"
android:layout_width="wrap_content"
android:layout_height="17px"
android:text="Amount of Bill $"
android:layout_x="40px"
android:layout_y="48px"
android:textColor="@color/white"
>
</TextView>
<TextView
android:id="@+id/widget29"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Percentage to Tip"
android:textColor="@color/white"
android:layout_x="40px"
android:layout_y="98px"
>
</Te开发者_Go百科xtView>
<TextView
android:id="@+id/widget30"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Number of People"
android:textColor="@color/white"
android:layout_x="40px"
android:layout_y="148px"
>
</TextView>
<TextView
android:id="@+id/widget31"
android:layout_width="wrap_content"
android:layout_height="18px"
android:text="Tip Amout $"
android:textColor="@color/white"
android:layout_x="40px"
android:layout_y="262px"
>
</TextView>
<TextView
android:id="@+id/widget32"
android:layout_width="wrap_content"
android:layout_height="18px"
android:text="Total Per Person $"
android:textColor="@color/white"
android:layout_x="40px"
android:layout_y="302px"
>
</TextView>
<Button
android:id="@+id/btncalculate"
android:layout_width="87px"
android:layout_height="wrap_content"
android:text="Calculate"
android:textColor="@color/black"
android:layout_x="40px"
android:layout_y="198px"
>
</Button>
<Button
android:id="@+id/btnreset"
android:layout_width="86px"
android:layout_height="wrap_content"
android:text="Reset"
android:textColor="@color/black"
android:layout_x="140px"
android:layout_y="198px"
>
</Button>
<EditText
android:id="@+id/txtbillamount"
android:layout_width="99px"
android:layout_height="36px"
android:text=""
android:textSize="18sp"
android:layout_x="200px"
android:layout_y="38px"
>
</EditText>
<EditText
android:id="@+id/txtpercentage"
android:layout_width="51px"
android:layout_height="36px"
android:text=""
android:textSize="18sp"
android:layout_x="200px"
android:layout_y="88px"
>
</EditText>
<EditText
android:id="@+id/txtpeople"
android:layout_width="51px"
android:layout_height="36px"
android:text=""
android:textSize="18sp"
android:layout_x="200px"
android:layout_y="138px"
>
</EditText>
<TextView
android:id="@+id/txttipamount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="@color/white"
android:layout_x="200px"
android:layout_y="262px"
>
</TextView>
<TextView
android:id="@+id/txtperperson"
android:layout_width="wrap_content"
android:layout_height="99px"
android:text=""
android:textColor="@color/white"
android:layout_x="200px"
android:layout_y="302px"
>
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="%" android:textColor="@color/white"
android:id="@+id/percentageview"
android:layout_x="265dip"
android:layout_y="92dip">
</TextView>
</AbsoluteLayout>
<LinearLayout
android:id="@+id/linearLayout"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</LinearLayout>
</LinearLayout>
use below on your remaining elements except admob.
layout_weight="1.0" layout_height="0dp"
use below on your admob wrapper layout
android:gravity="bottom"
For example,
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#000000">
<LinearLayout
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="0dp"
android:layout_weight="1.0">
// here is remaining elements
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:orientation="vertical"
android:id="@+id/ad_layout"
android:layout_height="wrap_content"
android:gravity="bottom">
// admob element here
</LinearLayout>
</LinearLayout>
and insert admob by code,
adView = new AdView(this, AdSize.SMART_BANNER, MY_AD_UNIT_ID);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
adView.setLayoutParams(params);
LinearLayout layout = (LinearLayout)findViewById(R.id.ad_layout);
layout.addView(adView);
adView.loadAd(new AdRequest());
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
<Button android:id="@+id/btnGetMoreResults"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Get more"
android:layout_alignParentBottom="true" />
</RelativeLayout>
Use your AdMob Design Parameters in place of Button code here.
This blog post will certainly help you:
http://www.ahotbrew.com/how-to-put-admob-banner-on-the-bottom
The important part here are android:layout_alignParentBottom=”true” for the AdView and android:layout_alignParentTop=”true” for the LinearLayout afterwards.
精彩评论