Relative layout not allowed on toolbar

I came across a strange warning while trying to customize the appearance of a toolbar. I put RelativeLayoutin android.support.v7.widget.Toolbarfor a reorganization Toolbar. Everything works and appears as expected on both the emulator and the device. The only problem is the annoying warning that appears in the XML file, as shown below:

warning screenshot

The question is what the actual problem is, how it can harm my application, and how I can solve this warning. How do I know it Toolbarbehaves like ViewGroup, why is it RelativeLayoutnot allowed to be a child? Thanks.

+4
1

Toolbar ViewGroup RelativeLayout's.

Android Studio 1.5.1, .

<android.support.v7.widget.Toolbar
                android:id="@+id/toolBar"
                android:layout_width="match_parent"
                android:layout_height="?actionBarSize"
                app:layout_scrollFlags="scroll|enterAlways"
                app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

                <RelativeLayout
                    android:id="@+id/toolBarTv"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/app_name"
                    android:textSize="18dp">
                </RelativeLayout>

            </android.support.v7.widget.Toolbar>

Android Studio , Platform, Platform .

. , .

+3

Source: https://habr.com/ru/post/1625830/


All Articles