LinearLayout and FrameLayout multiple errors in Android Studio

So I am currently making this app and this is the activity_maps.xml file that I am using/coding:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical">

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

<FrameLayout xmlns:android="https://schemas.android.com/apk/res/android"
    android:layout_height="match_parent"
    android:layout_width="match_parent">

<Button
    android:id="@+id/btnRestaurant"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:text="Nearby Restaurants"
    android:visibility="visible" />

<Button
    android:id="@+id/btnHospital"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:text="Nearby Hospitals"
    android:visibility="visible" />

<Button
    android:id="@+id/btnSchool"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:text="Nearby Schools"
    android:visibility="visible" />
</FrameLayout>

The errors which are showing are that whenever I hover my mouse above linearlayout it shows: layout_height attribute should be defined, layout_width attribute should be defined, Element LinearLayout doesn't have required attribute layout_height, Element LinearLayout doesn't have required attribute layout_width, Wrong orientation?No orientation specified, and the default is horizontal, yet this layout has multiple children where at least one has layout_width="match_parent". Then these are the errors when I hover above FrameLayout: layout_height attribute should be defined, layout_width attribute should be defined. These are the errors when I hover above the button tag: layout_height attribute should be defined, layout_width attribute should be defined. These are the errors when I hover above abdroid:id="@+id/btnwhatever", android:text="whatever", android:visibility="visible" tags they all say: Unexpected namespace prefix "android" found for tag Button. When I change the layout of the app to this:

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="350dp"
android:layout_height="500dp"

<FrameLayout xmlns:android="https://schemas.android.com/apk/res/android"
    android:layout_height="125dp"
    android:layout_width="75dp">

    <LinearLayout 
        xmlns:android="https://schemas.android.com/apk/res/android"
        xmlns:tools="https://schemas.android.com/tools"
        android:layout_height="75dp"
        android:layout_width="100dp"
        android:orientation="vertical">

        <Button
            android:id="@+id/btnRestaurant"
            android:layout_height="10dp"
            android:layout_width="10dp"
            android:text="Nearby Restaurants"
            android:visibility="visible" />

        <Button
            android:id="@+id/btnHospital"
            android:layout_height="10dp"
            android:layout_width="10dp"
            android:text="Nearby Hospitals"
            android:visibility="visible" />

        <Button
            android:id="@+id/btnSchool"
            android:layout_height="10dp"
            android:layout_width="10dp"
            android:text="Nearby Schools"
            android:visibility="visible" />

    </LinearLayout>
</FrameLayout>

However when I do that layout which shows no errors and then I open the map it says on the logcat: java.lang.RuntimeException: Binary XML file line #0: You must supply a layout_width attribute Please help, Thank you. PS I just took out the tools:context="" tag in the fragment for posting


As Mike said and also remove repeated xmlns xmlns:android="https://schemas.android.com/apk/res/android" from FrameLayout tag. Here is the code that I have tested:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:orientation="vertical">

        <fragment xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:map="http://schemas.android.com/apk/res-auto"
            xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/map"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"></fragment>

        <FrameLayout
            android:layout_height="match_parent"
            android:layout_width="match_parent">

            <Button
                android:id="@+id/btnRestaurant"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="Nearby Restaurants"
                android:visibility="visible" />

            <Button
                android:id="@+id/btnHospital"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="Nearby Hospitals"
                android:visibility="visible" />

            <Button
                android:id="@+id/btnSchool"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="Nearby Schools"
                android:visibility="visible" />
        </FrameLayout>
    </LinearLayout>
链接地址: http://www.djcxy.com/p/79950.html

上一篇: eclipse编译器或javac中的错误(“T的类型参数无法确定”)

下一篇: Android Studio中的LinearLayout和FrameLayout多个错误