Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
415 views
in Technique[技术] by (71.8m points)

android - EditText gravity affects hint text but not input text

I am trying to make the input text inside an editText come out at the bottom of it. When I use , <item name="android:gravity">bottom</item> the hint changes its position but the input text does not.

enter image description here

enter image description here

This is my xml code:

    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/registrationUsernameEditTextLayout"
        style="@style/grayEditTextLayoutHelperText"
        android:layout_width="0dp"
        android:layout_marginStart="16dp"
        android:layout_marginEnd="16dp"
        android:hint="@string/username"
        app:helperTextTextColor="@color/green"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.35">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/registrationUsernameEditText"
            style="@style/grayEditText"
            android:layout_width="match_parent"
            android:inputType="text" />
    </com.google.android.material.textfield.TextInputLayout>
    <style name="grayEditTextLayout" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
        <item name="android:layout_height">55sp</item>
        <item name="hintTextColor">@color/gray</item>
        <item name="android:textColorHint">@color/gray</item>
        <item name="boxStrokeColor">@color/text_edit_layout_outline_color</item>
        <item name="strokeWidth">2sp</item>
        <item name="backgroundTint">@null</item>
        <item name="boxCornerRadiusBottomEnd">7sp</item>
        <item name="boxCornerRadiusBottomStart">7sp</item>
        <item name="boxCornerRadiusTopEnd">7sp</item>
        <item name="boxCornerRadiusTopStart">7sp</item>
    </style>

    <style name="grayEditText">
        <item name="android:textColor">@color/gray_white</item>
        <item name="android:textSize">14sp</item>
        <item name="android:textCursorDrawable">@null</item>
        <item name="android:layout_height">50sp</item>
        <item name="android:gravity">bottom</item>
    </style>

    <style name="grayEditTextLayoutHelperText" parent="grayEditTextLayout">
        <item name="android:layout_height">70sp</item>
    </style>
question from:https://stackoverflow.com/questions/65849253/edittext-gravity-affects-hint-text-but-not-input-text

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...