如何在我的相对布局中重新排列我的文本视图?

how to rearrange my textview in my relativelayout?

这是我的布局截图:

我如何安排所有这些 TextView 以便它们具有良好的格式(标题是承担责任(意味着意识到)..)对齐等

<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"
    tools:context=".Menu"
    android:background="@android:color/holo_blue_bright"
    >


    <TextView
        android:text="*Follow safety guide for moving around the town and between towns."
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView25"
        android:gravity="left"

        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginBottom="51dp" />

    <TextView
    android:text="*Avoid crowds and do not participate actively in demonstrations even when it is related to programme work."
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/textView25"
    android:gravity="left"


        android:layout_below="@+id/textView25"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginTop="15dp" />

    <TextView
        android:text="*Avoid crowds and do not participate actively in demonstrations even when it is related to programme work."
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView25"
        android:gravity="left"

        android:layout_marginBottom="23dp"
        android:layout_above="@+id/textView25"
        android:layout_toRightOf="@+id/textView25"
        android:layout_toEndOf="@+id/textView25" />

    <TextView
    android:text="*keep this briefing pack in an accessible place, and the    emergency numbers in your mobile phone memory"
    android:layout_width="wrap_content"
    android:gravity="bottom"
    android:layout_height="wrap_content"
    android:id="@+id/textView28"

        android:layout_above="@+id/textView25"
        android:layout_toRightOf="@+id/textView25"
        android:layout_toEndOf="@+id/textView25"
        android:layout_marginBottom="46dp" />

    <TextView
        android:gravity="center"
        android:textColor="#000"
        android:textSize="15dp"
        android:text="Taking resposibility(means being aware)"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textView22"
        android:layout_marginTop="18dp"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <TextView
        android:text="*Avoid moving around town by yourself and always make others aware of your location."
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="left"
        android:id="@+id/textView25"

        android:layout_marginTop="76dp"
        android:layout_below="@+id/textView22"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <TextView
        android:text="*Share any security information that might have implications for Ballloon Ventures to the Country Manager or pc"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView24"
        android:gravity="left"

        android:layout_below="@+id/textView26"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginTop="30dp" />

    <TextView
        android:text="*If using host home accommondation,check that it is secure.if it is not,tell the Programme Coordinator"
        android:layout_width="wrap_content"
        android:gravity="bottom"
        android:layout_height="wrap_content"
        android:id="@+id/textView28"

        android:layout_marginTop="14dp"
        android:layout_below="@+id/textView24"
        android:layout_alignRight="@+id/textView25"
        android:layout_alignEnd="@+id/textView25" />

    <TextView
        android:text="*Report all incidents to your Programmer Cordinator."
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView26"
        android:gravity="left"

        android:layout_below="@+id/textView25"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginTop="55dp" />


</RelativeLayout>

因为如果我拖动一个 TextView,它会影响所有其他 TextView。

这样做的最佳做法是在您的代码视图和设计视图之间打开一个拆分视图,然后使用填充、边距、对齐、下方、上方等属性编辑代码以将文本放置在正确的位置等。请参阅 this 在相对布局中定位内容并将其与其他格式属性(如边距和填充)结合使用的指南。

正如@GabeSechan 所说,您需要了解 android:layout_xxx 属性在 RelativeLayout 中的含义.

当您通过布局编辑器在 RelativeLayout 中移动视图时,您需要在布局中考虑以下一些属性:

android:layout_above="@+id/textView25"
android:layout_below="@+id/textView24"
android:layout_toRightOf="@+id/textView25"
android:layout_toEndOf="@+id/textView25"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
  • android:layout_above="@+id/textView25"表示你想要textView25视图上面的View.

  • android:layout_below="@+id/textView24"表示你想要下面的ViewtextView25View.

  • 下面的属性表示你希望视图在TextView25视图的右侧:

    android:layout_toRightOf="@+id/textView25"
    android:layout_toEndOf="@+id/textView25"
    
  • 以下属性表示您希望视图与父布局的左侧对齐:

    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    

如果您想在 RelativeLayout 中编辑视图位置,请不要依赖通过布局编辑器拖放。你最好手动做,除非你想以后头疼。使用布局编辑器查看设计结果。

先用纸或想象设计,再编码。

尝试从中学习: