2011-05-05 179 views
0

我需要一些佈局幫助。我有一個按鈕的水平視圖,下面是按鈕的另一個線性佈局,然後是listview,然後是底部的AdView(AdMob)。我的問題是,底部的廣告查看疊加在列表視圖,我不能正確。看到我的代碼附加。任何幫助將不勝感激。謝謝。Android佈局問題

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/res/com.google.example" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout 
     android:id="@+id/Lay1" 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <HorizontalScrollView 
      android:scrollbars="none" 
      android:layout_height="wrap_content" 
      android:layout_width="fill_parent"> 
      <LinearLayout 
       android:layout_width="fill_parent" 
       android:gravity="center_vertical|center_horizontal" 
       android:layout_height="60px"> 
       <Button android:id="@+id/SCHButton_1" 
        style="@style/RSSButtonText" 
        android:background="@layout/rssbuttonshape"/> 
       <Button android:id="@+id/SCHButton_2" 
        style="@style/RSSButtonText" 
        android:background="@android:color/transparent"/> 
       <Button android:id="@+id/SCHButton_3" 
        style="@style/RSSButtonText" 
        android:background="@android:color/transparent"/> 
       <Button android:id="@+id/SCHButton_4" 
        style="@style/RSSButtonText" 
        android:background="@android:color/transparent"/> 
       <Button android:id="@+id/SCHButton_5" 
        style="@style/RSSButtonText" 
        android:background="@android:color/transparent"/> 
       <Button android:id="@+id/SCHButton_6" 
        style="@style/RSSButtonText" 
        android:background="@android:color/transparent"/> 
       <Button android:id="@+id/SCHButton_7" 
        style="@style/RSSButtonText" 
        android:background="@android:color/transparent"/> 
      </LinearLayout> 
     </HorizontalScrollView> 
     <LinearLayout 
      android:layout_height="wrap_content" 
      android:layout_width="fill_parent"> 
      <Button android:id="@+id/SCHButton_11" 
       android:text="Button11" 
       android:background="@drawable/button_no" 
       android:layout_width="120px" 
       style="@style/ButtonText2"> 
      </Button> 
      <Button android:id="@+id/SCHButton_12" 
      android:text="Button12" 
       android:background="@drawable/button_no" 
       android:layout_width="120px" 
       style="@style/ButtonText2"> 
      </Button> 
      <Button android:id="@+id/SCHButton_13" 
       android:text="Button13" 
       android:background="@drawable/button_no" 
       android:layout_width="120px" 
       style="@style/ButtonText2"> 
      </Button> 
      <Button android:id="@+id/SCHButton_14" 
      android:text="Button14" 
       android:background="@drawable/button_no" 
       android:layout_width="120px" 
       style="@style/ButtonText2"> 
      </Button> 
     </LinearLayout> 
     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 
      <ListView android:id="@id/android:list" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:background="#FFFFFF" 
       android:cacheColorHint="#00000000" 
       android:listSelector="@drawable/list_selector" 
       android:drawSelectorOnTop="false"> 
      </ListView> 
     </LinearLayout> 
    </LinearLayout> 
    <LinearLayout 
     android:id="@+id/adView" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="bottom" 
     android:layout_alignParentBottom="true" 
     android:layout_alignBottom="@+id/Lay1"> 
    </LinearLayout> 
</RelativeLayout> 

回答

0

試試這個:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/res/com.google.example" 
    android:layout_width="fill_parent" android:layout_height="fill_parent"> 
     <LinearLayout android:id="@+id/adView" 
     android:layout_width="fill_parent" android:layout_height="wrap_content" 
     android:gravity="bottom" android:layout_alignParentBottom="true" 
     /> 
    <LinearLayout android:id="@+id/Lay1" android:orientation="vertical" 
     android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_above="@+id/adview"> 
     <HorizontalScrollView android:scrollbars="none" 
      android:layout_height="wrap_content" android:layout_width="fill_parent"> 
      <LinearLayout android:layout_width="fill_parent" 
       android:gravity="center_vertical|center_horizontal" 
       android:layout_height="60px"> 
       <Button android:id="@+id/SCHButton_1" style="@style/RSSButtonText" 
        android:background="@layout/rssbuttonshape" /> 
       <Button android:id="@+id/SCHButton_2" style="@style/RSSButtonText" 
        android:background="@android:color/transparent" /> 
       <Button android:id="@+id/SCHButton_3" style="@style/RSSButtonText" 
        android:background="@android:color/transparent" /> 
       <Button android:id="@+id/SCHButton_4" style="@style/RSSButtonText" 
        android:background="@android:color/transparent" /> 
       <Button android:id="@+id/SCHButton_5" style="@style/RSSButtonText" 
        android:background="@android:color/transparent" /> 
       <Button android:id="@+id/SCHButton_6" style="@style/RSSButtonText" 
        android:background="@android:color/transparent" /> 
       <Button android:id="@+id/SCHButton_7" style="@style/RSSButtonText" 
        android:background="@android:color/transparent" /> 
      </LinearLayout> 
     </HorizontalScrollView> 
     <LinearLayout android:layout_height="wrap_content" 
      android:layout_width="fill_parent"> 
      <Button android:id="@+id/SCHButton_11" android:text="Button11" 
       android:background="@drawable/button_no" android:layout_width="120px" 
       style="@style/ButtonText2" /> 
      <Button android:id="@+id/SCHButton_12" android:text="Button12" 
       android:background="@drawable/button_no" android:layout_width="120px" 
       style="@style/ButtonText2" /> 
      <Button android:id="@+id/SCHButton_13" android:text="Button13" 
       android:background="@drawable/button_no" android:layout_width="120px" 
       style="@style/ButtonText2" /> 
      <Button android:id="@+id/SCHButton_14" android:text="Button14" 
       android:background="@drawable/button_no" android:layout_width="120px" 
       style="@style/ButtonText2" /> 
     </LinearLayout> 
     <LinearLayout android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 
      <ListView android:id="@id/android:list" 
       android:layout_width="fill_parent" android:layout_height="wrap_content" 
       android:background="#FFFFFF" android:cacheColorHint="#00000000" 
       android:listSelector="@drawable/list_selector" 
       android:drawSelectorOnTop="false" /> 
     </LinearLayout> 
    </LinearLayout> 

</RelativeLayout> 
+0

都能跟得上。不幸的是,現在的列表視圖重疊了底部的adView。任何其他想法? – Henry 2011-05-06 13:01:16

+0

使用上述佈局,請嘗試設置admob linearlayout的高度。這可能是因爲它是「wrap_content」,但它直到admob被繪製之後才知道大小。只需嘗試一下像android:layout_height =「50dp」 – jkhouw1 2011-05-06 13:42:30

0

試試這個

<LinearLayout 
     android:id="@+id/adView" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="bottom" 
     android:layout_alignParentBottom="true"  
     android:layout_below="@+id/Lay1"> 
    </LinearLayout>