在 LinearLayout 中将文本视图左对齐(水平)

Ayè*_*mza -1 java xml android android-layout android-xml

我试图让我的Textview左对齐已经尝试过。但android:gravity="left"什么也没发生。

这是我的 XML 代码:

  <LinearLayout
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:orientation="horizontal">
         <TextView
          android:id="@+id/textView11"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_margin="10dp"
          android:layout_weight="1"
          android:text="Email:"
          android:textSize="20dp"/>
        <EditText
          android:id="@+id/editTextAddress"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_margin="10dp"
          android:layout_weight="1"
          android:background="@drawable/bg"
          android:hint="Enter Address"/>
  </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

RKR*_*KRK 5

尝试使用此代码:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

<TextView
    android:id="@+id/textView11"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_margin="10dp"
    android:layout_weight="1"
    android:text="Email:"
    android:textSize="20dp"/>

<EditText
    android:id="@+id/editTextAddress"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/textView11"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_toEndOf="@+id/textView11"
    android:layout_weight="1"
    android:background="@drawable/bg"
    android:hint="Enter Address"/></RelativeLayout>
Run Code Online (Sandbox Code Playgroud)