I'm trying to set the new support.desing library that provides some lollipop visual effects to old android versions.
In this case, I'm triying to add the floating labels for the edittext, which is done with the widget.TextInputLayout:
To do this I have followed google's provided few indications:
I have downloaded the last support library (22.2.0) and included on graddle file.
compile 'com.android.support:design:22.2.0'
I have added the TextInputLayout in my xml this way:
<android.support.design.widget.TextInputLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginLeft="20dp">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="12"
android:hint="hint"
android:inputType="number"
android:id="@+id/edt" />
</android.support.design.widget.TextInputLayout>
But Android Studio is showing this in the layout preview:
Rendering failed with a known bug. Please try a rebuild.
The following classes could not be instantiated:
- android.support.design.widget.TextInputLayout (Open Class, Show Exception, Clear Cache)
Exception Details
java.lang.NoSuchFieldError: TextAppearance
This is the style I'm using:
<style name="MaterialTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/md_red_500</item>
<item name="colorPrimaryDark">@color/darkPrimaryColor</item>
<item name="colorAccent">@color/md_green_500</item>
<item name="android:textColorPrimary">@color/md_grey_900</item>
<item name="android:textColorSecondary">@color/md_grey_600</item>
</style>
EDIT-
TextInputLayout textInputCustomEndIcon = findViewById(R. id. editText); final TextInputEditText editText = new TextInputEditText(textInputCustomEndIcon. getContext()); textInputCustomEndIcon.
To change the hint color you have to use these attributes: hintTextColor and android:textColorHint . To change the bottom line color you have to use the attribute: boxStrokeColor .
Solved. Had to add this:
<android.support.design.widget.TextInputLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginLeft="20dp"
app:hintTextAppearance="@style/TextAppearence.App.TextInputLayout">
Where this just is:
<style name="TextAppearence.App.TextInputLayout" parent="@android:style/TextAppearance">
<item name="android:textColor">@color/accentColor</item>
</style>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With