android - 当我在样式中设置 OutlinedBox 时,TextInputLayout 不起作用
问题描述
implementation 'com.google.android.material:material:1.1.0'
在它不起作用之后处理布局添加的依赖项
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_below="@+id/textView"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<EditText
android:id="@+id/editTextCode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="10dp"
android:inputType="phone"
android:maxLength="6"
android:paddingStart="3dp"
android:drawableLeft="@android:drawable/stat_sys_phone_call"
android:gravity="start"
/>
</com.google.android.material.textfield.TextInputLayout>`
解决方案
使用 EditText 的 TextInputEditText。检查下面的代码
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayoutName"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/textInputLayoutEditTextName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name"
android:inputType="text"
android:text="Data" />
</com.google.android.material.textfield.TextInputLayout>
推荐阅读
- node.js - Google App Engine - 指定自定义构建依赖项
- bash - Bash 中 [[ -n $VAR ]] 和 [[ $VAR ]] 的区别
- reactjs - ReactJS/Express Axios POST 返回 404,来自 Postman
- angularjs - 控制器中 document.getElementById('#elementId') 的 Angularjs 单元测试失败
- r - 配对数据,两个变量进入列联表
- c - 使用 struct 中定义的类型作为 struct 中函数参数的类型
- primefaces - PrimeFaces的Dialog组件中的modal属性
- django - 如何将参数从一个模板发送到 django 中的另一个模板/视图?
- excel - 使用日期作为文本计算出现次数的 Excel 公式
- bash - 嵌入在 Perl 文件中的 Bash 脚本“mv -f”