首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >上面的android相对布局不起作用

上面的android相对布局不起作用
EN

Stack Overflow用户
提问于 2015-08-27 15:05:15
回答 3查看 2.9K关注 0票数 0

我有问题:在android studio的设计中看起来很完美,但当我在ganymotion或设备中运行我的应用程序时,我只有全屏的第二个布局这是我的源码

代码语言:javascript
运行
复制
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/choosetransactionuserimg"
>


<View
    android:layout_width="match_parent"
    android:layout_height="1dp"

    android:id="@+id/centerview"
    android:layout_centerVertical="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />


<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"

    android:background="#D9c42251"
    android:layout_above="@+id/centerview"
    android:id="@+id/relativeLayout">


    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Button"
        android:id="@+id/button2"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

</RelativeLayout>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:background="#000000"
    android:layout_alignParentStart="true"
    android:layout_below="@+id/centerview">
</RelativeLayout>

我不知道出了什么问题,如果有人知道解决方案,请帮助我,谢谢

EN

回答 3

Stack Overflow用户

发布于 2015-08-27 15:13:17

试试这个:

代码语言:javascript
运行
复制
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/choosetransactionuserimg"
>


<View
    android:layout_width="match_parent"
    android:layout_height="1dp"

    android:id="@+id/centerview"
    android:layout_centerVertical="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />


<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"

    android:background="#D9c42251"
    android:layout_above="@+id/centerview"
    android:id="@+id/relativeLayout">


    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Button"
        android:id="@+id/button2"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

</RelativeLayout>

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:background="#000000"
    android:layout_alignParentStart="true"
    android:layout_below="@+id/centerview">
</RelativeLayout>
票数 0
EN

Stack Overflow用户

发布于 2015-08-27 15:19:14

您需要使用here线性布局作为主布局。通过使用它,您将非常容易地管理您的屏幕。我正在使用这项专利,而我需要你所需要的类型设计。

  • 设置具有第一部分的线性布局添加第一个视图,在第二个视图中添加中间视图,在最后和第三个视图中添加底部/最后一个/第三个视图
  • 根据需要提供这三个部分的布局-鬼魂,如1st=0.25 2nd=1 3rd=0.25

下面是它的示例:

  1. http://www.7solutions.in/2013/10/weightweight-sum-in-android.html
  2. http://blog.stylingandroid.com/layout-weights-part-2/ http://www.7solutions.in/2013/10/weightweight-sum-in-android.html
票数 0
EN

Stack Overflow用户

发布于 2015-08-27 16:05:17

检查它:

代码语言:javascript
运行
复制
   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:id="@+id/choosetransactionuserimg"

    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight=".5"
              android:background="#D9c42251"

        android:id="@+id/relativeLayout">


        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="New Button"
            android:id="@+id/button2"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true" />

    </LinearLayout>


    <View
        android:layout_width="match_parent"
        android:layout_height="5dip"

        android:id="@+id/centerview"
        android:layout_gravity="center_vertical"
        android:background="@android:color/white"
        />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight=".5"
        android:orientation="vertical"
        android:background="@android:color/black"
        android:layout_below="@+id/centerview"
        android:id="@+id/relativeLayout2">


    </LinearLayout>

    </LinearLayout>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32242762

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档