Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/197.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 Relativelayout - Fatal编程技术网

在android中,如何在一个版面上显示一半的按钮,在另一个版面上显示一半的按钮?

在android中,如何在一个版面上显示一半的按钮,在另一个版面上显示一半的按钮?,android,android-relativelayout,Android,Android Relativelayout,我想设计一个布局,如下图所示: 我试着用相对布局来做,但没有找到解决方案。对于所有设备屏幕,它应处于相同的位置。我怎样才能实现它??? 我尝试了以下代码: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" andr

我想设计一个布局,如下图所示:

我试着用相对布局来做,但没有找到解决方案。对于所有设备屏幕,它应处于相同的位置。我怎样才能实现它??? 我尝试了以下代码:

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


如果您有任何建议,我们将不胜感激。

您可以将
按钮
声明置于
相对版面下方的
相对版面之外
然后把它放在你喜欢的地方

例如: 编辑:


您可以将
按钮
声明放在
相对布局
相对布局的底部之外 然后把它放在你喜欢的地方

例如: 编辑:



但我有两个相对的布局。一个在上面,另一个在下面。我想在两个相对的布局之间展示它。你不明白我的问题可能是什么。你用了一个主要的亲戚。在此布局中,您有两个RelativeLayouts和一个按钮。在这种情况下,您不需要将按钮放在“第三个”相对布局中,但我有两个相对布局。一个在上面,另一个在下面。我想在两个相对的布局之间展示它。你不明白我的问题可能是什么。你用了一个主要的亲戚。在此布局中,您有两个RelativeLayouts和一个按钮。在这种情况下,您不需要将按钮放在“第三个”相对视图中。请尝试使用具有两个子视图的父框架布局1。您的主要相对布局(顶部和底部有2个子项)2。中间的按钮,重心垂直,任何你想要的对齐方式都可能是正确的答案,但问题是,它没有响应。这意味着如果我将设备从hdpi更改为xdpi,它将无法工作。请尝试使用具有2个子视图的父框架布局1。您的主要相对布局(顶部和底部有2个子项)2。中间的按钮,重心垂直,任何你想要的对齐方式都可能是正确的答案,但问题是,它没有响应。这意味着如果我将设备从hdpi更改为xdpi,它将无法工作。
<?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>