如何显示一个按钮半上的一个布局,一半在Android的另一个布局? [英] How to show a button half on one layout and half on another layout in android?

查看:176
本文介绍了如何显示一个按钮半上的一个布局,一半在Android的另一个布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设计像下面的图片的布局:

I want to design a layout like the image below:

我试着使用相对布局做到这一点,但我没有拿出一个解决方案。它应该是在对所有设备屏幕的相同位置上。我怎样才能实现呢??? 我想这code:

I tried to do it using Relative layout but I did not come up with a solution. It should be in the same position for all device screen. How can I achieve it??? I tried this code:

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

    <RelativeLayout
        android:id="@+id/relative_layout_top"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/obaz" >

    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/relative_layout_bottom"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/relative_layout_top"
        android:background="@drawable/obaz2" >

        <Button
            android:id="@+id/bt_atoz"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_marginTop="-20dp"

            android:background="@drawable/button_active" />

    </RelativeLayout>

</RelativeLayout>

任何建议将AP preciated。

Any suggestion will be appreciated.

推荐答案

您可以把按钮声明你的 RelativeLayout的 relative_layout_bottom 然后将它放在你喜欢的地方。

You can put the Button declaration outside of your RelativeLayout relative_layout_bottom and then place it where you like.

例如: 编辑:

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

    <RelativeLayout
        android:id="@+id/relative_layout_top"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/obaz" >
    </RelativeLayout>

    <Button
        android:id="@+id/bt_atoz"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:background="@drawable/button_active" />

    <RelativeLayout
        android:id="@+id/relative_layout_bottom"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/relative_layout_top"
        android:background="@drawable/obaz2" >
    </RelativeLayout>

</RelativeLayout>

这篇关于如何显示一个按钮半上的一个布局,一半在Android的另一个布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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