我使用以下代码浮动编辑文本。
<android.support.design.widget.TextInputLayout
android:id="@+id/username_text_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/searchbtn"
android:contentDescription="Using for Floating label">
<EditText
android:id="@+id/editphone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/inputNumber"
android:imeOptions="actionSearch"
android:inputType="phone"
android:maxLength="15" />
</android.support.design.widget.TextInputLayout>
但它没有在预览中呈现并在android studio中获得跟随渲染问题。
java.lang.NumberFormatException: Attribute '?attr/colorControlActivated' not found. Are you using the right theme?
at com.android.layoutlib.bridge.impl.ResourceHelper.getColor(ResourceHelper.java:76)
at com.android.layoutlib.bridge.impl.ResourceHelper.getColorStateList(ResourceHelper.java:155)
at android.content.res.BridgeTypedArray.getColor(BridgeTypedArray.java:299)
at android.support.design.widget.CollapsingTextHelper.setCollapsedTextAppearance(CollapsingTextHelper.java:191)
at android.support.design.widget.TextInputLayout.setHintTextAppearance(TextInputLayout.java:270)
at android.support.design.widget.TextInputLayout.<init>(TextInputLayout.java:111)
at android.support.design.widget.TextInputLayout.<init>(TextInputLayout.java:82)