Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relative Layout is not allowed inside Toolbar

I'm facing strange warning, trying to customize the Toolbar appearance. I put RelativeLayout inside android.support.v7.widget.Toolbar to reorganize Toolbar. Everything works and appears as expected on both emulator and device. The only problem is the annoying warning that appears in .xml file as seen below:

screenshot of the warning

The question is what is the actual problem, how can it harm my application and how can I solve this warning. As I know Toolbar behaves as ViewGroup, why RelativeLayout is not allowed to be it's child? Thanks.

like image 894
Evgeniy Mishustin Avatar asked Oct 18 '22 17:10

Evgeniy Mishustin


1 Answers

Toolbar extends from ViewGroup and RelativeLayout's too.

I've tried that on Android Studio 1.5.1 and i couldn't see that problem.

<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>

You should be able to update your Android Studio to the last version or checking if you are using outdated Platform, then you need to just update that Platform to the last version.

And then it won't show up.or perhaps it will fixed in the next update.

like image 55
ʍѳђઽ૯ท Avatar answered Oct 21 '22 07:10

ʍѳђઽ૯ท