最近google引入了新的Android设计库,介绍了如何使用TextInputLayout
字段来启用EditText的Floating Hint功能。
没有太多可用的指导here .
这个页面说
you can now wrap it in a TextInputLayout
但不知道,因为智能预测 (Ctrl+SPACE) 不会预测 TextInputLayout 的任何属性。所以我的问题是:
我们如何获取该组件底层的 EditText?
我们如何从 EditText 中获取数据?
最佳答案
TextInputLayout
扩展了 ViewGroup
类。
这意味着您必须将 EditText
包装在 TextInputLayout
中。
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="hint"
android:id="@+id/editText1" />
</android.support.design.widget.TextInputLayout>
关于android - 如何在新的 android 设计库中使用 TextInputLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30571596/