I use TextInputLayout
to get password from user like this:
<android.support.design.widget.TextInputLayout
android:id="@+id/RegisterPassInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
app:passwordToggleEnabled="true"
android:layout_marginRight="16dp"
android:layout_toStartOf="@+id/RegisterPassImg">
<EditText
android:id="@+id/RegisterPassET"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:hint="@string/Password"
android:inputType="textPassword"
android:maxLength="40" />
</android.support.design.widget.TextInputLayout>
and the result is:
But i want something like this:
How can i set passwordToggle gravity align left of the editText.
For lots of reasons I disabled rtl
support in manifest
android:supportsRtl="false"
Barak
In your TextInputLayout
, add this argument:
android:layoutDirection="rtl"
Edit:
for API < 17 (Using android.support.v4.view.ViewCompat
):
TextInputLayout inputLayout = (TextInputLayout) findViewById(R.id.RegisterPassInput);
ViewCompat.setLayoutDirection(inputLayout, ViewCompat.LAYOUT_DIRECTION_RTL);
来源:https://stackoverflow.com/questions/43968840/change-passwordtoggle-gravity-to-the-left-for-rtl-language