android TextInputLayout中的hint显示与重影
2017-07-07 09:41
2221 查看
素材设计库版本是 com.android.support:design:25.3.1
1、只需要在EditText标签下写hint
2、不需要在代码中调用函数setHint
3、TextInputLayout和EditText的layout_width皆写为match_parent, 写为wrap_content会导致不显示hint,或者是发生重影。
![](https://oscdn.geek-share.com/Uploads/Images/Content/202007/06/a041c87f67181d99a58f024682aa90b3)
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/discover_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="标题"
android:inputType="text" />
</android.support.design.widget.TextInputLayout>
1、只需要在EditText标签下写hint
2、不需要在代码中调用函数setHint
3、TextInputLayout和EditText的layout_width皆写为match_parent, 写为wrap_content会导致不显示hint,或者是发生重影。
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/discover_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="标题"
android:inputType="text" />
</android.support.design.widget.TextInputLayout>
相关文章推荐
- 利用TextInputLayout实现hint浮动显示(一)
- Android下EditText的hint的一种显示效果------FloatLabelLayout
- 利用TextInputLayout实现hint浮动显示(二)
- android:hintText与android:inputType详解
- android 布局: LinearLayout如何使TextView中的内容居中显示
- Android 5.0新控件——TextInputLayout
- Android Design Support Library——TextInputLayout
- Error when inflating android.support.design.widget.TextInputLayout
- Android This text field does not specify an inputType or a hint 解决
- Android:实现EditText在获得焦点后消去hint,失去焦点后再显示原来的hint
- Android 5.0新控件——TextInputLayout
- Android M新控件之FloatingActionButton,TextInputLayout,Snackbar,TabLayout的使用
- Android Design Support Library(2)- TextInputLayout的使用
- Android学习系列第一弹之《warning:This text field does not specify an inputType or a hint》
- Android Support Design - TextInputLayout
- android:hintText与android:inputType详解
- android 布局: LinearLayout如何使TextView中的内容居中显示
- Android:This text field does not specify an inputType or a hint
- Android开发出现”This text field does not specify an inputType or a hint“
- Android M新控件之FloatingActionButton,TextInputLayout,Snackbar,TabLayout的使用