如何设置具有 2 个值的布局_Above?
现在,我的布局看起来像下面两张图片之一,具体取决于屏幕的确切尺寸。将其安装在一个“玩游戏”上!按钮位于顶部,另一方面,版权文本位于顶部。
我想要做的是将图像放在广告视图和顶部文本框/布局的较高部分之间。根据不同的屏幕尺寸,顶部的条目可能会有所不同。我希望根本没有这个问题...我知道如何将其放在图像视图下方,但不要将其放在这两个项目上方。
到目前为止,我已经尝试了一个relativeLayout,它包含底部变量,并告诉图像位于其上方,但位于AdView 下方。问题是,RelativeView 的顶部清晰地显示在顶部,尽管它被设置为wrap_content 并且下面的值都没有那么高。
我还考虑过将文本顶部与按钮顶部对齐,反之亦然,但我在脑海中看到了一个可能丑陋的界面,其中顶部按钮可能更大,或者是按钮的一部分版权文本被遮盖。
所以,我正在寻找两种解决方案之一。一种告诉我的图像位于按钮和文本这两个项目之上的方法,或者某种包装上下文的方法,以便我可以位于包装值之上。
这是我测试过的相关 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>
Right now, I have a layout that looks like one of the two images below, depending on the exact size of the screen. Bot that on one, the Play Game! button is on top, and on the other, the copyright text is on top.
What I'm trying to do is to put an image between the adview and the higher of the top text box/layout. Depending on different screen sizes, the entry that's on top can vary. I would like to not have this problem at all... I know how to put it below the imageview, but not put it above both items.
So far, I've tried a relativeLayout that encloses the bottom variables, and told the image to be above that, but below the AdView. Problem is, the top of the RelativeView goes clear to the top, despite it being set to wrap_content and none of the below values go that high.
I've also considered aligning either the top of the text to the top of the button, or visa versa, but I'm seeing a potentially ugly interface in my mind, one in which the top button might be bigger, or part of the copyright text obscured.
So, I'm looking for one of two solutions. A way to tell my image to be above 2 items, the button and the text, or some way to wrap the context such that I can just be above the wrapped value.
Here's the relevant XML code I've tested.
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经制作了一个适合您的布局 - 它看起来像这样:
编辑:尝试这个...
使用此布局(将顶部按钮替换为您的广告)
(自上次编辑以来进行了一些更改以使用花药相对布局......)
I've made a layout that will work for you - it looks like this:
Edit: Try this one...
Use this layout (replace the top button with your ad)
(changed a bit since last edit to use anther relative layout...)