【发布时间】:2015-12-31 11:31:21
【问题描述】:
RelativeLayout in Android Studio
我有一个水平 LinearLayout,其中我有一个 RelativeLayout,我希望另一个 RelativeLayout 在它下面,同样贯穿整个 xml 文件,但布局出现在前一个布局的右侧
我尝试将 RelativeLayout 的上边距设置为某个随机值,例如 60sp,它位于前一个 RelativeLayout 之下,但是当我添加 TextView 时,TextView 不会显示在设计视图中
After adding textview to RelativeLayout
如何将 Layout 定位在之前的 RelativeLayout 下方?以及如何将 TextViews 添加到此 RelativeLayout 并显示它们?
<?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:layout_below="@id/ -
布局显示正确,因为您的父布局方向是水平的