Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/182.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓布局-如何将广告单元与底部对齐,并将按钮放置在广告单元上方_Android_Android Layout - Fatal编程技术网

Android 安卓布局-如何将广告单元与底部对齐,并将按钮放置在广告单元上方

Android 安卓布局-如何将广告单元与底部对齐,并将按钮放置在广告单元上方,android,android-layout,Android,Android Layout,我试图让按钮和广告单元位于屏幕底部,按钮直接位于广告单元上方。但是按钮仍然在页面的中间。有什么想法吗 <?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" androi

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

<?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>

删除

android:layout_centerInParent="true"

从你的
linerallayout
,这应该可以达到目的。

你可以尝试将你的线性布局设置为
android:layou over=“@+id/banner\u adview”


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

buttons.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>

<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>