Java 如何在Android中使用TextInputLayout和EditText
在我的应用程序中,我想使用Java 如何在Android中使用TextInputLayout和EditText,java,android,android-edittext,material-design,android-textinputlayout,Java,Android,Android Edittext,Material Design,Android Textinputlayout,在我的应用程序中,我想使用TextInputLayout,为此,我编写了以下代码。 但在运行应用程序后,不显示编辑文本的任何笔划 只需显示空的编辑文本 我的结果图像: 我的代码: <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.andro
TextInputLayout
,为此,我编写了以下代码。但在运行应用程序后,不显示
编辑文本的任何笔划
只需显示空的编辑文本
我的结果图像:
我的代码:
<?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=".ui.login.send_phone.SendPhonePage">
<ImageView
android:id="@+id/sendPhone_logo"
android:layout_width="@dimen/_150mdp"
android:layout_height="@dimen/_150mdp"
android:layout_marginTop="@dimen/_30mdp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:src="@mipmap/ic_launcher_round" />
<!--Phone number-->
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/signInFrag_phoneInpLay"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/_15mdp"
android:layout_marginLeft="@dimen/_15mdp"
android:layout_marginEnd="@dimen/_15mdp"
android:layout_marginRight="@dimen/_15mdp"
app:boxStrokeColor="@color/colorAccent"
android:layout_marginTop="@dimen/_30mdp"
app:boxStrokeWidth="@dimen/_1mdp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/sendPhone_logo">
<EditText
android:id="@+id/signInFrag_phoneEdt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:gravity="left|center_vertical"
android:hint="@string/insertYourPhoneNumber"
android:inputType="phone"
android:maxLength="11"
android:maxLines="1"
android:paddingLeft="@dimen/_10mdp"
android:paddingRight="@dimen/_10mdp"
android:singleLine="true"
android:textColorHint="@color/colorLightGray"
android:textSize="@dimen/_10mdp"
app:drawableRightCompat="@drawable/ic_outline_phone" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
我使用了这个依赖项:implementation'com.google.android.material:material:1.2.1'
和这个样式
如何修复它?使用文本输入文本
而不是编辑文本
并删除android:background=“@android:color/transparent”使用文本输入文本
而不是编辑文本
并删除android:background=“@android:color/transparent”
,谢谢我的朋友,在你的帮助下我改变了密码。现在显示我的笔划,但我的语言是RTL,提示是RTL语言。但当将此提示文本移到上方时,在EditText的左侧显示空白。但我想显示这个提示空白空间我对编辑文本!怎么可能呢?谢谢我的朋友,在你的帮助下我改变了密码。现在显示我的笔划,但我的语言是RTL,提示是RTL语言。但当将此提示文本移到上方时,在EditText的左侧显示空白。但我想显示这个提示空白空间我对编辑文本!怎么可能呢?