Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TextInputLayout] prefixText position is wrong when endIconMode is set #2089

Closed
sdex opened this issue Feb 21, 2021 · 4 comments
Closed

[TextInputLayout] prefixText position is wrong when endIconMode is set #2089

sdex opened this issue Feb 21, 2021 · 4 comments

Comments

@sdex
Copy link

sdex commented Feb 21, 2021

Description: prefixText position is wrong when endIconMode is set
Screenshot from 2021-02-21 12-06-03

Expected behavior: Prefix text should be properly aligned.
Screenshot from 2021-02-21 12-06-18

Source code:

                <com.google.android.material.textfield.TextInputLayout
                    android:id="@+id/contact_container"
                    style="@style/Widget.Design.TextInputLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="8dp"
                    app:endIconDrawable="@drawable/ic_call"
                    app:endIconMode="custom"
                    app:prefixText="+65"
                    app:prefixTextAppearance="@style/TextAppearance.AppCompat.Medium">

                    <com.google.android.material.textfield.TextInputEditText
                        android:id="@+id/contact"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="Contact"
                        tools:text="61234561"
                        android:inputType="phone" />

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

Android API version: any

Material Library version: 1.3.0

Device: any + Android Studio layout editor

@sdex sdex added the bug label Feb 21, 2021
@felipeska
Copy link

Hello, I have the same issue, I'm curious about this because I'm not using endIconMode

error

First field was input manually.

Second field was filled using setText

@felipeska
Copy link

hello @sdex this could be related wit the issue #773

This fix worked for me:

inputLayout.prefixTextView.updateLayoutParams {
    height = ViewGroup.LayoutParams.MATCH_PARENT
}
inputLayout.prefixTextView.gravity = Gravity.CENTER

112352191-90f7ab00-8c98-11eb-8e59-373120093320

@sdex
Copy link
Author

sdex commented Mar 24, 2021

@felipeska thanks for sharing this.
I used the dirty workaround, wrapped it with FrameLayout, and put ImageButton at the end.

@drchen drchen self-assigned this Jun 24, 2021
@drchen
Copy link
Contributor

drchen commented May 18, 2022

Looks like a duplicate of #1773

@drchen drchen closed this as completed May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants