我想在我的 android 应用程序中集成 android.support.design.widget.TextInputLayout
。我已将 jar 文件 android-support-design.jar 从 sdk 复制到我的应用程序 lib 文件夹。我在我的电子邮件 EditText 的 xml 文件中添加了以下代码,
<!-- Email Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp">
<EditText android:id="@+id/input_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:hint="Email" />
</android.support.design.widget.TextInputLayout>
在我的 layout.xml 文件中添加此代码时,出现如下错误,
Exception raised during rendering: com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup
Exception details are logged in Window > Show View > Error Log
The following classes could not be instantiated:
- android.support.design.widget.TextInputLayout (Open Class, Show Error Log)
See the Error Log (Window > Show View) for more details.
我该如何解决这个问题…
原文由 SHIDHIN.T.S 发布,翻译遵循 CC BY-SA 4.0 许可协议
如果您使用 AndroidStudio,则不应包含 android-support-design.jar。相反,在你的 build.gradle 中像下面这样写:
编辑:如果这不起作用,您可能正在使用不同的版本。在 Windows 中,转到:
在 Mac 上:
该目录包含许多版本文件夹。在您的 build.gradle 上使用最新版本。