Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

element LinearLayout must be declared

I have updated my android studio and now I have a problem in my main.xml, it displays the following error: element LinearLayout must be declared

this is my code:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    android:gravity="center_vertical|center_horizontal"
    >
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/monBouton"
        android:text="Cliquez ici !"
        >
    </Button>
</LinearLayout>

this is the error message:

error : Execution failed for task ':app:compileDebugJava'. Compilation failed; see the compiler error output for details.

error : cannot find symbol variable action_settings

How can I solve it?

like image 505
MeBex Avatar asked Feb 20 '14 19:02

MeBex


People also ask

How do you declare a LinearLayout?

To create a linear layout in which each child uses the same amount of space on the screen, set the android:layout_height of each view to "0dp" (for a vertical layout) or the android:layout_width of each view to "0dp" (for a horizontal layout). Then set the android:layout_weight of each view to "1" .

What is LinearLayout?

Android LinearLayout is a view group that aligns all children in either vertically or horizontally.

How to set weight in LinearLayout in android?

It's android:layout_weight . Weight can only be used in LinearLayout . If the orientation of linearlayout is Vertical, then use android:layout_height="0dp" and if the orientation is horizontal, then use android:layout_width = "0dp" . It'll work perfectly.

What is layout_ weight in android studio?

In a nutshell, layout_weight specifies how much of the extra space in the layout to be allocated to the View. LinearLayout supports assigning a weight to individual children. This attribute assigns an "importance" value to a view, and allows it to expand to fill any remaining space in the parent view.


1 Answers

Your layout files must be in res/layout folder.

Providing Resources

like image 102
vbarinov Avatar answered Nov 13 '22 13:11

vbarinov