I have met a problem when I try to use the TextInputLayout and TextInputEditText. Here is my code
<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SignUpActivity">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Enter Password"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="52dp"
android:inputType="textPassword"
android:lines="1"
android:hint="Enter Passwrod"/>
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
And that's the screen shown in the design page Design Error Page
There should be something shown in the design page. I have check several youtube tutorial videos and those cant help me solve the problems.
Here is my build.gradle (module)
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
namespace 'com.james.kfarm'
compileSdk 33
defaultConfig {
applicationId "com.james.kfarm"
minSdk 24
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled 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.7.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.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'
//Splash Screen API
implementation 'androidx.core:core-splashscreen:1.0.0-beta02'
}
I have read several questions about the problems of using textinputlayout and textinputedittext. Some answers suggest that upgrading the version of "androidx.appcompat:appcompat" and "com.google.android.material:material". However I have upgraded them into the newest version and it dont work.
I have also rebuilt the project as the question "Android Studio cannot show design layout after adding a view" suggest
It would be a great help and comfort to me if anyone could help solve the problems. Thanks for reading this long question.