将新的TextInputLayout用于EditText的渲染问

将新的TextInputLayout用于EditText的渲染问

本文介绍了将新的TextInputLayout用于EditText的渲染问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在尝试设置新的support.desing库,该库为旧的android版本提供一些棒棒糖的视觉效果.

I'm trying to set the new support.desing library that provides some lollipop visual effects to old android versions.

在这种情况下,我试图为edittext添加浮动标签,这是通过widget.TextInputLayout完成的:

In this case, I'm triying to add the floating labels for the edittext, which is done with the widget.TextInputLayout:

为此,我遵循了Google提供的一些指示:

To do this I have followed google's provided few indications:

  • 我已经下载了最后一个支持库(22.2.0),并包含在graddle文件中.

  • I have downloaded the last support library (22.2.0) and included on graddle file.

编译'com.android.support:design:22.2.0'

compile 'com.android.support:design:22.2.0'

我已经通过以下方式在xml中添加了TextInputLayout:

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>

但是Android Studio在布局预览中显示了此信息:

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>

编辑-

推荐答案

已解决.必须添加:

<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">

这就是这里:

<style name="TextAppearence.App.TextInputLayout" parent="@android:style/TextAppearance">
    <item name="android:textColor">@color/accentColor</item>
</style>

这篇关于将新的TextInputLayout用于EditText的渲染问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 19:25