2011-05-28 95 views
0

相对布局的作品,但是当我这样做时,我所有的文本浏览和按钮都会丢到屏幕的左上角,请帮忙。Android AdMob屏幕底部的屏幕不工作

main.xml中

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 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/pattern_carbon_fiber_dark"> 

<com.google.ads.AdView 
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
android:id="@+id/adView" 
android:layout_width="fill_parent" 
ads:adSize="BANNER" 
ads:adUnitId="xxxxxxxxxxxxxx" 
ads:loadAdOnCreate="true" 
android:visibility="visible" 
android:layout_alignParentBottom="true" 
android:layout_gravity="bottom" 
android:layout_height="wrap_content"> 
</com.google.ads.AdView> 

<TextView android:text="Silent Mode" android:layout_height="wrap_content"   android:id="@+id/textView1" android:layout_width="wrap_content"></TextView> 
<ToggleButton android:layout_height="wrap_content" android:text="Silent Mode" android:id="@+id/silentbutton" android:layout_width="wrap_content" android:textOff="OFF" android:textOn="ON"></ToggleButton> 
<TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Wifi "></TextView> 
<ToggleButton android:layout_width="wrap_content" android:text="ToggleButton" android:layout_height="wrap_content" android:id="@+id/wifibutton"></ToggleButton> 
<TextView android:layout_width="wrap_content" android:id="@+id/textView3" android:text="@string/network" android:layout_height="wrap_content"></TextView> 
<TextView android:layout_gravity="center" android:text="@string/blank" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/textView4"></TextView>   

</RelativeLayout> 

当我做一个线性布局切换按钮和textviews都很好,但广告然后转到屏幕的中心。请帮忙。

谢谢!

+0

做一个的LinearLayout在哪里? – sgarman 2011-05-28 23:32:41

+0

没关系我修好了。谢谢您的帮助! – Test2e31234234 2011-05-29 00:40:07

回答

1

约linearlayout.setGravity了android的javadoc:

公共无效setGravity(INT重力)

自:API等级1 描述了孩子的意见如何定位。默认为GRAVITY_TOP。 如果此布局具有VERTICAL方向,则会控制放置所有子视图的位置,如果有额外的垂直空间。如果此布局具有HORIZONTAL方向,则会控制孩子的对齐。 相关XML属性

安卓重力 参数

重力见重力


所以它只是并不意味着与线性布局工作。我建议你要么

  • 变更的广告成分
  • 或使用相对布局的秩序,然后经常给上部件positionning更好的控制。

问候, 斯特凡

+0

谢谢,帮了我很多! – Test2e31234234 2011-05-30 04:28:33