2011-05-10 54 views
0

我使用這個佈局xml顯示我的活動和admob: 首先我認爲它會改變上面的佈局,當admob可用,但它不是... 你們有什麼想法嗎?如何在admob可用時移動android佈局?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@drawable/wonder" 
> 
<TextView 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="@string/hello" 
android:textColor="#000" 
/> 
<ListView 
android:id="@+id/auto" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:headerDividersEnabled="false" 
android:footerDividersEnabled="false"/> 
<LinearLayout 
xmlns:myapp="http://schemas.android.com/apk/res/com.anim.list" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content"> 
<com.admob.android.ads.AdView android:id="@+id/ad" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    myapp:backgroundColor="#000000" 
    myapp:primaryTextColor="#FFFFFF" 
    myapp:secondaryTextColor="#CCCCCC" /> 
</LinearLayout>  
</LinearLayout> 

更新:這是我的RelativeLayout

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:myapp="http://schemas.android.com/apk/res/com.anim.list" 
android:id="@+id/master" 
android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/wonder" 
> 
<TextView 
android:id="@+id/inf" 
android:layout_alignParentTop="true" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="@string/hello" 
android:textColor="#000" 
/> 
<ListView 
android:id="@+id/auto" 
android:layout_above="@+id/ad" 
android:layout_below="@+id/inf" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:headerDividersEnabled="false" 
android:footerDividersEnabled="false"/> 
<com.admob.android.ads.AdView 
    android:id="@+id/ad" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    myapp:backgroundColor="#000000" 
    myapp:primaryTextColor="#FFFFFF" 
    myapp:secondaryTextColor="#CCCCCC" 
    android:layout_alignParentBottom="true" 
    /> 
</RelativeLayout> 

updated screenshot

解決

對不起哥們,我用這個佈局,以解決我的問題

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" 
      android:background="@drawable/wonder"> 
<LinearLayout android:layout_width="fill_parent" 
       android:id="@+id/home_layout" 
       android:orientation="vertical" 
       android:layout_above="@+id/ad_layout" 
       android:layout_height="wrap_content"> 
    <!-- Put all your application views here, such as buttons, textviews, edittexts and so on --> 
    <TextView 
     android:id="@+id/inf" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/hello" 
     android:textColor="#000"     
    />   
    <ListView 
     android:id="@+id/auto" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:headerDividersEnabled="false" 
     android:footerDividersEnabled="false"     
    /> 
</LinearLayout> 
<LinearLayout android:layout_width="fill_parent" 
       android:id="@+id/ad_layout" 
       android:layout_height="wrap_content" 
       android:gravity="bottom" 
       android:layout_alignParentBottom="true"> 
<com.google.ads.AdView 
    xmlns:ads="http://schemas.android.com/apk/res/com.anim.list" 
    android:id="@+id/adView" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    ads:adSize="BANNER" 
    ads:adUnitId="a14db7f475a6f8d" 
/> 
</LinearLayout> 
</RelativeLayout> 

現在,我明白了!謝謝!

+0

你爲什麼不使用你想要什麼用相對佈局實現不能使用LinearLayout來完成,因爲如果LL – ingsaurabh 2011-05-10 05:01:14

+0

中發生向下移動,那麼它仍然不起作用......我的意思是,如果沒有廣告,當廣告可用時,listview應該填充其餘佈局廣告應該推動列表視圖...有沒有什麼不同,當我使用相對或線性,它只是相同... – BolbazarMarme 2011-05-10 06:24:24

+0

不會的情況下,不是案件改變你的XML使用現實L並張貼在這裏然後我會建議你什麼改變你應該在其中實現你想要的 – ingsaurabh 2011-05-10 06:27:56

回答

0

取下XML您的AD瀏覽代替改變它的LinearLayout

<LinearLayout 
    android:layout_below="@+id/TextView01" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:id="@+id/layout_ad" android:layout_height="wrap_content"/> 

並在代碼

LinearLayout layout = (LinearLayout) findViewById(R.id.layout_ad);    

AdWhirlLayout adWhirlLayout = new AdWhirlLayout(this, "your key");   
Display d = this.getWindowManager().getDefaultDisplay();  
RelativeLayout.LayoutParams adWhirlLayoutParams = new RelativeLayout.LayoutParams(d.getWidth(), 52);   
layout.addView(adWhirlLayout, adWhirlLayoutParams); 

這是我在我的應用程序如何實現

+0

我已經做到了,正如你所看到的那樣....在佈局的底部有一個空的空間......(截圖)對不起:( – BolbazarMarme 2011-05-10 06:59:08

+0

我不明白...,這只是一個佈局;它怎麼會這麼困難,像這樣...?對我來說意義很大 – BolbazarMarme 2011-05-10 07:01:26

+0

k我想出來你必須在代碼中設置一些寬度像這樣RelativeLayout.LayoutParams adWhirlLayoutParams = new RelativeLayout.LayoutParams(d .getWidth(),52); – ingsaurabh 2011-05-10 07:07:17

0

使用的RelativeLayout和標誌與佈局的頂視圖:上述= 「@ + ID/your_ad」

+0

男人,你似乎累了...去得到一些睡眠 – BolbazarMarme 2011-05-10 06:03:18