LinearLayout flagged if used in CardView
Asked Answered
T

2

12

I have used a LinearLayout in a CardView to get a kind of social media login button look and it all runs fine, but Android Studio flags Element LinearLayout is not allowed here. I was wondering why this may be the case? My xml is this :

<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>
Turbine answered 12/12, 2014 at 9:48 Comment(4)
probably some sdk hitches. clean your project and try againSchonfeld
It's more of an IDE hitch. Cleaning didn't work for me, but simply restarting Android Studio fixed this.Margaretemargaretha
Same happened to me, and as said by @Margaretemargaretha it seems to be an IDE problem, simply restarting the IDE fixed itInflatable
Now even restarting is not working what to do??? I have restarted the entire system, cleaned the project and I have tried "Invalidata Caches/Restart" too, it's really frustrating now.....Pinniped
W
26

Just to have a proper answer, as @Blacklight said in comments, it is an IDE issue so restarting it should fix the problem.

Welldefined answered 6/2, 2015 at 10:40 Comment(1)
this is the associated issue : code.google.com/p/android/issues/detail?id=81362Sulfaguanidine
J
2

Apart from other suggestions and the above answer, this issue happenes on me if I didn't upgrade my support library to AndroidX, in this case is CardView. So from

android.support.v7.widget.CardView

will need to be change to

androidx.cardview.widget.CardView

and the warning shall now disappears.

enter image description here

Jacobsen answered 26/8, 2019 at 18:34 Comment(1)
Perfect, that was the issue. Thanks!Swanherd

© 2022 - 2024 — McMap. All rights reserved.