Hint is overlapping with startIconDrawable in TextInputLayout

128 Views Asked by At

I am trying to use TextInputLayout in my Login form and have been trying to make it look like this

image_link

But instead it looks like this

image_link

I have already tried to fix the margin, and every thing, I have tried looking in YouTube for other projects where people used this syntax, but none face the problem I face, This is the code for the xml.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".SignUp">



    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Sign Up"
        android:textStyle="bold"
        android:textSize="25dp"
        android:layout_margin="20dp"
         />


    <com.google.android.material.textfield.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        app:boxBackgroundColor="@color/white"
        app:boxCollapsedPaddingTop="25dp"
        app:startIconDrawable="@drawable/baseline_person_24"
        android:layout_marginStart="30dp"
        android:layout_marginEnd="30dp">


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

    <Button
        android:id="@+id/button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:text="Button" />

</LinearLayout>
2

There are 2 best solutions below

0
Yaseen On

Finally, the problem has been resolved, what I did was

  • Uninstalled my Android Studio, and
  • Removed the .gradle folder from C:\Users\UserName,
  • Removed the Android folder and Android Open Source folder from C:\Users\Username\AppData\Local,
  • Removed the AndroidStudio folders from C:\Users\ya922\AppData\Local\Google, and
  • Removed the Android folder from C:\Program Files\Android
  • and then installed the same version which is Android Studio Hedgehog | 2023.1.1 Patch 2

after setting up everything, I created a new project to check if the problem was still there, but everything was working well!

I inspected the projects I made earlier, and found that the problem was still there and upon comparing the build.gradle of both the projects I found that there were few differences between their dependencies, so I copied those from the new project to the old one and its been working fine since then.

My build.gradle(Project)

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id("com.android.application") version "8.2.2" apply false
    id("org.jetbrains.kotlin.android") version "1.9.22" apply false
}

My build.gradle(module)

plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.android")
}

android {
    namespace = "com.example.splashscreen"
    compileSdk = 34

    defaultConfig {
        applicationId = "com.example.splashscreen"
        minSdk = 21
        targetSdk = 34
        versionCode = 1
        versionName = "1.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

dependencies {

    implementation("androidx.core:core-ktx:1.10.1")
    implementation("androidx.appcompat:appcompat:1.6.1")
    implementation("com.google.android.material:material:1.9.0")
    implementation("androidx.constraintlayout:constraintlayout:2.1.4")
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.5")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}

My settings.gradle

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.name = "Splash Screen"
include(":app")

Thanks @AbhishekTiwari for helping me out!

0
Ankul Parmar On

I had same problem with latest dependency

  implementation 'com.google.android.material:material:1.11.0'

instead of that

I downgraded my dependency to one version lower

my current dependency

implementation 'com.google.android.material:material:1.10.0'

This fixed the issue!! Works like charm for me!!