【发布时间】:2021-09-11 06:24:05
【问题描述】:
我以前从未见过这种情况,也不知道是什么原因造成的,我的第一选择是在片段中用一段 java 代码隐藏提示,但我失败了,现在我只想找到一个 XML 解决方案。
这发生在每个领域,我找不到这里的布局有什么问题,有什么见解吗?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/faq_contato_nome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_nome_contato"
android:inputType="textPersonName"
android:lines="1"
android:padding="10dp"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/faq_contato_telefone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_telefone_contato"
android:inputType="phone"
android:lines="1"
android:padding="10dip"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/faq_contato_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_email_contato"
android:inputType="textEmailAddress"
android:lines="1"
android:padding="10dip"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/faq_contato_nome_empresa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_empresa_contato"
android:inputType="text"
android:lines="1"
android:padding="10dip"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/faq_contato_telefone_empresa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_tel_empresa_contato"
android:inputType="phone"
android:lines="1"
android:padding="10dip"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/faq_contato_matricula"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Digite sua matricula (Opcional)"
android:inputType="number"
android:lines="1"
android:padding="10dip"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<sinapse.com.br.estilo.component.CustonSpinner
android:id="@+id/faq_contato_spinner_assunto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:hintText="@string/title_spinner" />
<EditText
android:id="@+id/faq_contato_campo_mensagem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_marginEnd="2dp"
android:layout_marginStart="2dp"
android:gravity="center_horizontal|bottom"
android:hint="@string/hint_areamensagem"
android:inputType="textMultiLine" />
<TextView
android:id="@+id/faq_contato_numero_caracteres"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:text="@string/caracteres" />
<com.google.android.material.button.MaterialButton
android:id="@+id/faq_contato_btn_enviar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
android:layout_gravity="right"
android:text="@string/enviar" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/faq_contato_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="13dp" />
</LinearLayout>
</ScrollView>
【问题讨论】:
-
如果您使用 TextInputLayout,请始终仅在 TextInputLayout 中提供提示,而不是在编辑文本中提供提示。
标签: java android xml android-studio kotlin