Невозможно разместить TextInputEditText поверх макета TextInput. AndroidStudio - PullRequest
1 голос
/ 03 августа 2020

Итак, я столкнулся с проблемой, когда я пытался преобразовать свой EditText в TextInputEditText в TextInputLayout из библиотеки com.google.material.

Я не могу разместить текст TextInputEdit поверх TextInputLayout Вот скриншот. Click Here For Screenshot

As you can see it is a bit off from both the top and left.

login.xml

     

build.gradle (app: module)

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.annotation:annotation:1.1.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
    implementation 'com.google.firebase:firebase-auth:19.3.1'
    implementation 'com.google.firebase:firebase-database:19.3.1'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.navigation:navigation-fragment:2.3.0'
    implementation 'androidx.navigation:navigation-ui:2.3.0'
    implementation 'com.github.castorflex.smoothprogressbar:library:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.mediarouter:mediarouter:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.google.firebase:firebase-analytics:17.2.2'
}

Обновление: - Исправлено смещение оси X. Теперь проблема только со смещением оси Y. Щелкните здесь, чтобы увидеть новый снимок экрана

Ответы [ 2 ]

1 голос
/ 04 августа 2020

Примените эти изменения:

  • используйте последнюю стабильную версию компонентов материала implementation 'com.google.android.material:material:1.1.0'
  • используйте android:layout_height="wrap_content" в TextInputLayout
  • remove android:padding="5dp" в TextInputLayout
  • используйте android:layout_height="match_parent" в TextInputEditText
  • удалите android:hint=" Password" в TextInputEditText
  • замените app:passwordToggleEnabled="true" на app:endIconMode="password_toggle"

Просто используйте:

    <com.google.android.material.textfield.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="  Password"
        android:importantForAutofill="no"
        app:errorEnabled="true"
        app:endIconMode="password_toggle"
        ...>

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/signuppasswordfeild"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:inputType="textPassword"
            />

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

введите описание изображения здесь

0 голосов
/ 03 августа 2020

Попробуйте установить android: layout_width и android: layout_height TextInputEditText на "match_parent". Вы также можете попытаться удалить android: padding = "5dp" из TextInputLayout, если хотите, чтобы он подходил идеально. Также удалите android: hint = "Password" из второго TextInputLayout. Вот почему вы получаете двойные подсказки для пароля.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...