【发布时间】:2019-08-27 02:34:19
【问题描述】:
我在 CardView 中使用了 LinearLayout 来获得一种社交媒体登录按钮的外观,一切运行良好,但 Android Studio 标记 Element LinearLayout is not allowed here。我想知道为什么会这样?我的 xml 是这样的:
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_below="@id/cv_fb"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardElevation="3dp"
>
<LinearLayout
android:id="@+id/ll_entitlement_extend_google"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/white"
android:clickable="true"
android:gravity="center"
android:paddingTop="10dp"
android:paddingBottom="10dp"
>
<ImageView
android:layout_weight="1"
android:layout_width="75dp"
android:layout_height="75dp"
android:src="@drawable/google_icon"/>
<TextView
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Connect with Google +"/>
<ImageView
android:layout_weight="1"
android:layout_width="25dp"
android:layout_height="25dp"
android:src="@drawable/ic_chevron_right_black"/>
</LinearLayout>
</android.support.v7.widget.CardView>
【问题讨论】:
-
可能是一些 sdk 故障。清理您的项目并重试
-
这更像是一个 IDE 故障。清理对我不起作用,但只需重新启动 Android Studio 即可解决此问题。
-
同样的事情发生在我身上,正如@Blacklight所说,这似乎是一个IDE问题,只需重新启动IDE即可解决它
-
现在连重启都不行怎么办???我已经重启了整个系统,清理了项目,我也尝试过“无效数据缓存/重启”,现在真的很沮丧.....
标签: android android-layout android-linearlayout android-cardview