Search code examples
javaandroidandroid-studiolayoutandroid-linearlayout

The linear layout format keeps showing errors, I've tried all I can but still not working.?


Have being trying to build this layout but I don't while its not running yet '''

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#90A4AE"
    android:orientation="vertical">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:elevation="4dp">


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

'''


Solution

  • You forgot to close the Linear Layout ! Use the code below. Always remember that you have to close the tag either by using ".../>" at end or "</..>" after adding widgets inside it...

    Please note that I also replaced the old support library tablayout with a tablayout from material library

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#90A4AE"
    android:orientation="vertical">
    
    <com.google.android.material.tabs.TabLayout
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:elevation="4dp">
        
    </com.google.android.material.tabs.TabLayout>
    
    </LinearLayout>