android - RTL 安卓 :hint in TextInputLayout

标签 android right-to-left textinputlayout

我有这个 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>

我要hint文字显示在右侧,但使用后 layoutDirection , textAlignment仍然显示在左侧,我该怎么做?

我看到了this link但不能解决我的问题。

最佳答案

    <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"/>

关于android - RTL 安卓 :hint in TextInputLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54627321/

相关文章:

Android Intent 类似于 Gmail 的 attach Intent

java - 我如何将操作绑定(bind)到代号中的对话框 "OK"按钮

android - SearchView AppCompatActivity 中的空指针?

java - Android更改语言配置会弄乱布局

jquery - 如何使用 jquery 步骤向导从右到左的步骤

android - 文本输入布局颜色

Android TextInputLayout 提示与 EditText 提示重叠

android - 是否可以在 widget.TextInputLayout 中管理工具提示

android - 适用于 Android 的 Titanium/Appcelerator : Multiple density images not found

uikit - NSMutableParagraphStyle 忽略 NSWritingDirectionNatural,阿拉伯语文本默认为 LTR