[70237 Closed] Compiler Warning - LinearLayout has invalid child element ImageButton

While compiling an Android app, I am getting a warning telling me that my LinearLayout has an invalid child element, an ImageButton. I can’t quite figure out why this is happening. the full error is here:

Warning 1 The element ‘LinearLayout’ has invalid child element ‘ImageButton’. List of possible elements expected: 'Theme, Window, AlertDialog, FragmentAnimation, WindowAnimation, View, ViewGroup, ViewStub, InputMethod, SpellChecker, AccessibilityService, ActionMenuItemView, AbsListView, AbsSpinner, AnalogClock, Button, Chronometer, CompoundButton, CheckedTextView, EditText, FrameLayout, ExpandableListView, Gallery, GridView, ImageSwitcher, ImageView, ToggleButton, RelativeLayout, LinearLayout, GridLayout, ListView, PreferenceFrameLayout, MenuView, IconMenuView, ProgressBar, SeekBar, StackView, RatingBar, RadioGroup, TableLayout, TableRow, TabWidget, TextAppearance, TextSwitcher, TextView, TextViewAppearance, SelectionModeDrawables, SuggestionSpan, InputExtras, AutoCompleteTextView, PopupWindow, ViewAnimator, ViewFlipper, AdapterViewAnimator, AdapterViewFlipper, ViewSwitcher, ScrollView, HorizontalScrollView, Spinner, DatePicker, TwoLineListItem, SlidingDrawer, GestureOverlayView, QuickContactBadge, RotarySelector, WeightedLinearLayout, CalendarView, NumberPicker, TimePicker, Drawable, StateListDrawable, AnimationDrawa…

Any pointers as to why that is occurring? My layout file looks like this:

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

  <TextView
    android:id="@+id/question_text_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="24dp"/>

  <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <Button
      android:id="@+id/true_button"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/true_button"/>

    <Button
      android:id="@+id/false_button"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/false_button"/>

  </LinearLayout>

  <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <ImageButton
      android:id="@+id/previous_button"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:src="@drawable/arrow_left"
      android:contentDescription="@string/previous_button" />

    <ImageButton
      android:id="@+id/next_button"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:src="@drawable/arrow_right"
      android:contentDescription="@string/next_button" />
    
  </LinearLayout>
  
</LinearLayout>

Exiting and restarting Visual Studio fixed the problem. I have been having occasional error messages when using the code editor. Unfortunately I can’t recall what the messages were.

Thanks, logged as bugs://70237: Compiler Warning - LinearLayout has invalid child element ImageButton

bugs://70237 got closed as fixed for release Bradbury Class

It comes down to the xml schema we use. you can ignore the warnings it gives you (it does let you compile). The next build will not show this warning for ImageButton.