0

现在,我的布局看起来像下面两个图像之一,具体取决于屏幕的确切大小。一个机器人,玩游戏!按钮在顶部,另一方面,版权文本在顶部。

在此处输入图像描述 在此处输入图像描述

我要做的是在 adview 和顶部文本框/布局的较高位置之间放置一个图像。根据不同的屏幕尺寸,顶部的条目可能会有所不同。我想根本没有这个问题......我知道如何将它放在图像视图下方,但不将它放在两个项目之上。

到目前为止,我已经尝试了一个包含底部变量的 relativeLayout,并告诉图像高于它,但低于 AdView。问题是,RelativeView 的顶部清晰到顶部,尽管它被设置为 wrap_content 并且以下值都没有达到那么高。

我也考虑过将文本的顶部与按钮的顶部对齐,反之亦然,但我在脑海中看到了一个可能丑陋的界面,其中顶部按钮可能更大,或者是版权文本被遮盖。

所以,我正在寻找两种解决方案之一。一种告诉我的图像高于 2 项、按钮和文本的方法,或者某种包装上下文的方法,这样我就可以高于包装的值。

这是我测试过的相关 XML 代码。

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" 
  android:orientation="vertical">
  <com.google.ads.AdView android:id="@+id/adView" ads:loadAdOnCreate="true" ads:adSize="BANNER" ads:adUnitId="@string/admob_unit_id" android:layout_width="wrap_content" android:layout_height="wrap_content" ></com.google.ads.AdView>
  <ImageView android:src="@drawable/start_logo" android:gravity="center" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/logo_view" android:layout_below="@+id/adView" android:layout_above="@+id/buttons_copyright"></ImageView>
  <RelativeLayout android:id="@+id/buttons_copyright" android:layout_width="fill_parent" android:layout_alignParentLeft="true" android:layout_alignParentBottom="true"  android:layout_alignParentTop="false" android:layout_height="wrap_content">
   (NOTE: LOTS OF STUFF GOES HERE)
  </RelativeLayout>
</RelativeLayout>
4

1 回答 1

4

我已经制作了一个适合您的布局 - 它看起来像这样:编辑:试试这个......

在此处输入图像描述

使用此布局(用您的广告替换顶部按钮)(自上次编辑后稍作更改以使用另一种相对布局...)

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <Button
        android:text="Button"
        android:id="@+id/button1"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"></Button>
    <TextView
        android:text="Version Text"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_alignBaseline="@+id/instructions_button"
        android:layout_toLeftOf="@+id/instructions_button"
        android:layout_marginLeft="5dp" />
    <Button
        android:id="@+id/instructions_button"
        android:layout_width="wrap_content"
        android:text="Instructions"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:minWidth="100dp"
        android:layout_alignParentBottom="true" />
    <TextView
        android:text="Game Name Text"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_alignBaseline="@+id/scores_button"
        android:layout_toLeftOf="@+id/scores_button"
        android:layout_marginLeft="5dp" />
    <Button
        android:id="@+id/scores_button"
        android:layout_width="wrap_content"
        android:text="High Scores"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:minWidth="100dp"
        android:layout_above="@+id/instructions_button" />
    <RelativeLayout
        android:id="@+id/copyright_layout"
        android:layout_above="@+id/scores_button"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent">
        <TextView
            android:text="Copyright text goes here and goes on and on a bit and fills up a few lines and looks ok generally and keeps on going and going and going and going onto many lines longer thatn it should etct"
            android:textSize="10sp"
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:layout_alignTop="@+id/play_button"
            android:layout_toLeftOf="@+id/play_button"
            android:layout_marginLeft="5dp" />
        <Button
            android:id="@+id/play_button"
            android:layout_width="wrap_content"
            android:text="Play Game!"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:minWidth="100dp"
            android:layout_above="@+id/scores_button" />
    </RelativeLayout>
    <ImageView
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:id="@+id/imageView1"
        android:layout_margin="5dp"
        android:layout_above="@+id/copyright_layout"
        android:layout_below="@+id/button1"
        android:src="@drawable/map"
        android:scaleType="centerCrop" />
</RelativeLayout>
于 2011-06-03T22:42:57.863 回答