CardView中不允许元素LinearLayout [英] Element LinearLayout is not allowed in CardView
问题描述
注意:请先阅读问题,然后再将其标记为重复!我已经提到过类似的问题并没有解决我的问题.
Note: PLEASE READ THE QUESTION before mark it as duplicate! I've mentioned that the similar question has not solved my problem.
我将android.support.v7.widget.CardView
用于布局xml.但是,当我在CardView
中放置LinearLayout
时,Android Studio给我以下错误" 此处不允许使用元素LinearLayout ".
I am using android.support.v7.widget.CardView
for my layout xml. However when I place a LinearLayout
within the CardView
, Android Studio gives me the following error "Element LinearLayout is not allowed here".
实际上 ANY 类型的小部件(例如TextView)会导致此错误,我尝试了
In fact ANY types of widgets (like TextView) would cause this error, I have tried solutions from LinearLayout flagged if used in CardView link, which was to restart Android Studio. But it did not work. Below is my xml code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
我还将发布屏幕截图!
可能是什么问题?
推荐答案
因此,请确保一系列建议:
So, a collection of suggestions, just to be sure:
- 重新启动AS
- 使缓存无效&重新启动
- 检查是否添加了正确的依赖项
- 清洁和清洁重建项目
- 在另一个文件/项目中尝试相同的代码
- 试图找到项目的备份
- 也许计算机重新启动
- restart AS
- invalidating Caches & restart
- Check if the right dependencies are added
- clean & rebuild of project
- try same code in another file/project
- trying to find a backup of your project
- maybe computer reboot
这篇关于CardView中不允许元素LinearLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!