2

我试图让按钮和广告单元位于屏幕底部,按钮直接位于广告单元上方。但是按钮仍然在页面的中间。有任何想法吗?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/wallpaperview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_gravity="center"
        android:scaleType="centerCrop" />

   <LinearLayout
       android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/banner_adview"
        android:layout_centerInParent="true"
       android:orientation="horizontal" 
       >
       <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/button_use" 
            android:onClick="onUse" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/button_share" 
            android:onClick="onShare" />
    </LinearLayout>

    <com.mobclix.android.sdk.MobclixMMABannerXLAdView
        android:id="@+id/banner_adview"
        android:layout_width="320dip"
        android:layout_height="50dip"
        android:layout_gravity="center"
        android:layout_alignParentBottom="true"
      />


</RelativeLayout>
4

3 回答 3

0

您可以尝试使用将线性布局设置为android:layout_above="@+id/banner_adview".

于 2013-01-30T22:23:21.277 回答
0

消除

android:layout_centerInParent="true"

从你的LineraLayout,这应该可以解决问题。

于 2013-01-30T20:17:11.323 回答
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/lib/com.google.ads"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
    android:orientation="vertical" >  
  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true" >
    <include layout="@layout/buttons" />
  <com.mobclix.android.sdk.MobclixMMABannerXLAdView
    android:id="@+id/banner_adview"
    android:layout_width="320dip"
    android:layout_height="50dip"
    android:layout_gravity="center"
    android:layout_alignParentBottom="true"
  />
 </RelativeLayout>

创建按钮 xml 并在主布局中包含它

按钮.xml

<LinearLayout
   android:layout_width="fill_parent"
    android:layout_height="wrap_content"
   android:orientation="horizontal" 
   >
   <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_use" 
        android:onClick="onUse" />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_share" 
        android:onClick="onShare" />
</LinearLayout>
于 2014-12-09T08:25:17.957 回答