Set up a control within a parent LinearLayout

0

I have a LinearLayout parent that contains the property; android:gravity="center" with that all the controls within it will be centered, now I need some controls to be left for example. Any ideas?

XML

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="20dp"
        android:text="Iniciar Sesión"
        android:textAlignment="center"
        android:textSize="22sp" />

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginTop="8dp">

        <EditText
            android:id="@+id/et_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:drawableRight="@mipmap/ic_account_box_black_24dp"
            android:hint="Email"
            android:inputType="textEmailAddress" />

    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginTop="8dp">

        <EditText
            android:id="@+id/et_password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:drawableRight="@mipmap/ic_lock_black_24dp"
            android:hint="Contraseña"
            android:inputType="textPassword" />

    </android.support.design.widget.TextInputLayout>

    <CheckBox
        android:id="@+id/checkBox3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignStart="@+id/editText7"
        android:layout_below="@+id/editText7"
        android:layout_marginTop="5dp"
        android:text="Mostrar contraseña"
        android:textColor="#004D40" />

    <CheckBox
        android:id="@+id/checkBox5"
        android:layout_width="160dp"
        android:layout_height="wrap_content"
        android:layout_alignStart="@+id/checkBox3"
        android:layout_below="@+id/checkBox3"
        android:layout_marginTop="9dp"
        android:text="Recordar cuenta"
        android:textColor="#004D40" />

    <android.support.v7.widget.AppCompatButton
        android:id="@+id/btn_login"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimary"
        android:text="Aceptar"
        android:textColor="@android:color/white" />

    <TextView
        android:id="@+id/tv_register"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:text="¡Recuperar contraseña!"
        android:textColor="@color/colorAccent" />

</LinearLayout>
    
asked by Ashley G. 19.11.2017 в 22:50
source

1 answer

0

To the component that you want to be on the left, put this on:

android:layout_gravity="left"

If this does not work for you, put the component you want to align it to the left inside a RelativeLayout that has match_parent in width, then align it to the left of the RelativeLayout:).

<RelativeLayout  android:layout_width="match_parent"
    android:layout_height="wrap_content">
 <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true" />
</RelativeLayout>
    
answered by 19.11.2017 в 23:56