RTL安卓:一丝TextInputLayout

问题描述 投票:0回答:3

我有这样的XML布局:

 <?xml version="1.0" encoding="utf-8"?>
    <androidx.constraintlayout.widget.ConstraintLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layoutDirection="locale" 
        android:textDirection="rtl"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".app.storey.view.StoreyInsertFragment">

    <com.google.android.material.textfield.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="somthing"
            app:layout_constraintEnd_toEndOf="parent"
            android:layout_marginEnd="8dp"
            android:layout_marginTop="8dp"
            app:layout_constraintStart_toStartOf="parent"
            android:layout_marginStart="8dp"
            app:layout_constraintHorizontal_bias="0.0" 
            app:layout_constraintTop_toTopOf="parent">

        <com.google.android.material.textfield.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

    </com.google.android.material.textfield.TextInputLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

我想在右边,但在使用后qazxsw POI qazxsw POI文戏,hint仍然显示在左边,我该怎么办呢?

我看到layoutDirection但不解决我的问题。

android right-to-left textinputlayout
3个回答
0
投票
textAlignment

0
投票

0
投票

如果您使用的API> 17,然后尝试下面的属性设置为您的EditText

    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/text_input_user_name"
        style="@style/LoginInputLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_marginStart="@dimen/margin_editText_end_start"
        android:layout_marginTop="@dimen/margin_end_edit_text"
        android:layout_marginEnd="@dimen/margin_editText_end_start"
        android:layout_marginBottom="@dimen/margin_end_edit_text"

        app:hintAnimationEnabled="true"
        app:hintEnabled="true"
        >

        <androidx.appcompat.widget.AppCompatEditText
            android:id="@+id/edt_user_name"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center|start"
            android:gravity="center|start"
            android:textAlignment="center"
            android:hint="@string/user_name"
            android:inputType="textMultiLine"
            android:maxLength="8"
            android:padding="20dp"
            android:textColor="@color/ches_white"
            android:textColorHint="@color/ches_white"
            android:textSize="@dimen/text_size_login"/>

另外,你需要提示设置为您的EditText,而不是你的TextInputLayout和在其他的答案中提到设置重力权利。

© www.soinside.com 2019 - 2024. All rights reserved.