如何在ImageView的顶部创建一个按钮,它对准屏幕的底部? [英] How to create a button on top of ImageView and align it to the bottom of the screen?

查看:136
本文介绍了如何在ImageView的顶部创建一个按钮,它对准屏幕的底部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用我的 XML 文件中对的ImageView 顶部的按钮。当运行此code时,按钮显示在屏幕的左手侧上的其它按钮的顶

I want to have a button on top of ImageView using my xml file. When I run this code, the button appears to the left hand side of the screen on top of other buttons.

有没有人对如何做才能对的ImageView顶部的按钮,但在屏幕底部的任何想法。

Does anyone have any idea on what to do to have a button on TOP of ImageView but at the bottom of the screen.

到目前为止,我有以下几点:

So far I have the following:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   ......

    <ImageView
        android:id="@+id/filter_image_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_toRightOf="@id/filter_linear_layout" />

//this is the button I want to have on top of the ImageView
    <Button
        android:id="@+id/display_RGB"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="@drawable/button_blue_red_transluscent"
        android:text="@string/display_RGB"
        android:textColor="@android:color/white" />

</RelativeLayout>

不强求,只要其在屏幕底部的地方,但在中心。

Not too fussy as long as its somewhere at the bottom of the screen but in the center.

推荐答案

您可以把他们在自己的RelativeLayout,那么你可以很容易地操纵相对的ImageView按钮的位置。

You can put them in their own RelativeLayout, then you can manipulate the location of the button relative to the ImageView quite easily.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_toRightOf="@id/filter_linear_layout" >

    <ImageView
        android:id="@+id/filter_image_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        />

    <Button
        android:id="@+id/display_RGB"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/button_blue_red_transluscent"
        android:text="@string/display_RGB"
        android:textColor="@android:color/white"
        android:layout_centerHorizontal="true"
        android:layout_below="@id/filter_image_view"
         />
</RelativeLayout>

如果这不是你在找什么,你需要发布的它目前的样子样本图像,你想要怎样看。

If this is not what you are looking, you'll need to post a sample image of how it currently looks and how you wants it to look.


编辑的XML布局。如果你想在ImageView的水平居中,将它添加到ImageView的:

Edited the XML layout. If you want the ImageView to center horizontally, add this to ImageView:

    android:layout_centerHorizontal="true"

和你可能希望通过添加这按钮添加的ImageView和按键之间的间距一些:

And you'll probably want to add some spacing between ImageView and Button by adding this to Button:

    android:layout_marginTop="8dp"

这篇关于如何在ImageView的顶部创建一个按钮,它对准屏幕的底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆