关于android:在RelativeLayout下面的位置RelativeLayout

Position RelativeLayout below RelativeLayout

Android Studio中的RelativeLayout

我有一个水平LinearLayout,其中我有一个RelativeLayout,我希望另一个RelativeLayout在它下面,并且同样在整个xml文件中,但是Layout出现在上一个Layout的右端

我试图将RelativeLayout的顶部边距设置为某个随机值,例如60sp,它位于上一个RelativeLayout的下方,但是当我添加TextView时,TextView不会出现在设计视图中

将textview添加到RelativeLayout之后

如何将Layout放置在以前的RelativeLayout下方? 以及如何将TextViews添加到此RelativeLayout并显示它们?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/calcbackground"
android:weightSum="1">

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="53dp"
    >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:text="SHIFT"
        android:id="@+id/shifttextiew"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:text="DEG"
        android:id="@+id/degtextview"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/shifttextiew"
        android:layout_toEndOf="@+id/shifttextiew"
        android:layout_marginLeft="31dp"
        android:layout_marginStart="31dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:text="RAD"
        android:id="@+id/radtextview"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/degtextview"
        android:layout_toEndOf="@+id/degtextview"
        android:layout_marginLeft="30dp"
        android:layout_marginStart="30dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:text="GRAD"
        android:id="@+id/gradtextview"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/radtextview"
        android:layout_toEndOf="@+id/radtextview"
        android:layout_marginLeft="41dp"
        android:layout_marginStart="41dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="12345678910"
        android:id="@+id/calculationtextview"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/shifttextiew"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

</RelativeLayout>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="60sp">

</RelativeLayout>

</LinearLayout>


您告诉它在此处为android:orientation="horizontal"

使您的LinearLayout垂直。


我看到您的代码没有在根布局上添加任何方向。如果您没有添加任何方向,那么它将在水平方向上起作用。请在您的根布局上添加以下代码,希望它会起作用。

1
  android:orientation="vertical"

对您的父级线性布局使用orientation =" vertical"属性


在最顶层的视图组中需要更改(LinearLayout)

1
android:orientation="vertical"

代替

1
android:orientation="horizontal"

制作单独的布局并使用include布局标签根据您的需要放置两个布局