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?
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" .
Android LinearLayout is a view group that aligns all children in either vertically or horizontally.
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.
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.
Your layout files must be in res/layout
folder.
Providing Resources
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With