The specified orientation is not specified, but the default is horizontal. This is a common source of errors when children are added dynamically.

My application cannot be started because there is an error in my XML file. One of my LinearLayouts is marked in red, and when I hover over the cursor, I see the following error message: The specified orientation is not specified, and the default is horizontal. This is a common source of errors when children are added dynamically.

You can see my code below, and I will mark the line, I get this message as follows: <- error message →

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"> <LinearLayout android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="1" android:orientation="vertical" > <Button android:id="@+id/btn1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Fragment 1" /> <Button android:id="@+id/btn2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Fragment 2" /> <Button android:id="@+id/btn3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Fragment 3" /> </LinearLayout> <LinearLayout <- error message -> android:id="@+id/myFragment" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="3" /> </LinearLayout> 
+7
android xml
source share
3 answers

You must add android:orientation="horizontal" to the LinearLayout block, the same thing you did above.

+10
source share

LinearLayout requires orientation, horizontal or vertical.

You can install it in code:

 myLinearLayout.setOrientation(LinearLayout.VERTICAL); 
0
source share

See below, you need to add orientation for the layout.

 <LinearLayout android:orientation="horizontal" android:id="@+id/myFragment" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="3" /> 
0
source share

All Articles