This is what I actually have as a result:
As you can see value to right of Current HP is moved to right instead to stay close to "Current HP" textview like the rest of values. Why is that so? This is my code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:background="@color/semiTrans"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/llHeader"
android:layout_margin="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/text"
android:layout_marginRight="5dp"
app:srcCompat="@android:drawable/ic_dialog_info" />
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:gravity="center_vertical|center_horizontal"
android:text="CONTINUE INFO"
android:textColor="#000"
android:textSize="25sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/rl2"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/llHeader"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true">
<TextView
android:id="@+id/currentHp"
android:textStyle="bold"
android:layout_width="168dp"
android:layout_height="wrap_content"
android:text="Current HP: "
android:textSize="18sp"/>
<TextView
android:id="@+id/nextHp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/currentHp"
android:text="Next +10HP: "
android:textSize="18sp"/>
<TextView
android:id="@+id/fullHp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/nextHp"
android:text="HP fully recovered: "
android:textSize="18sp"/>
<TextView
android:id="@+id/currentHpValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/currentHp"
android:layout_toRightOf="@+id/currentHp"
android:text="a"
android:textSize="18sp"/>
<TextView
android:id="@+id/nextHpValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/currentHp"
android:layout_toEndOf="@+id/nextHp"
android:layout_toRightOf="@+id/nextHp"
android:text="a"
android:textSize="18sp"/>
<TextView
android:id="@+id/fullHpValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/fullHp"
android:layout_alignBottom="@+id/fullHp"
android:layout_toEndOf="@+id/fullHp"
android:layout_toRightOf="@+id/fullHp"
android:text="a"
android:textSize="18sp"/>
<TextView
android:id="@+id/tvAdditionalInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_below="@id/fullHp"
android:textSize="18sp"
android:layout_centerHorizontal="true"
android:text="Additional info"/>
</RelativeLayout>
<Button
android:id="@+id/dialogButtonOK"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/rl2"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_marginHorizontal="10dp"
android:layout_marginBottom="10dp"
android:background="@drawable/button"
android:text=" Ok " />
</RelativeLayout>
I was trying to solve this by setting padding and margin to 0 but it did not work. I do not know what else Ishould added.
question from:
https://stackoverflow.com/questions/65849120/android-textview-is-moved-to-right 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…