views:

16

answers:

1

I have some preoblems when it comes to designing a view, As you can see I have open my xml file with a view-tag, and it gives me error. why is that? if I change it to LinearLayout than it works.

<View xmlns:android="http://schemas.android.com/apk/res/android"
class="android.app.SearchDialog$SearchBar"
android:id="@+id/search_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:focusable="true"
android:descendantFocusability="afterDescendants">

<!-- Outer layout defines the entire search bar at the top of the screen -->
<TextView 
    android:id="@+id/search_badge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="2dip"
    android:drawablePadding="0dip"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:textColor="?android:attr/textColorPrimaryInverse" />

<!-- Inner layout contains the app icon, button(s) and EditText -->
<LinearLayout
A: 

I don't think you can create a view like that in xml. The purpose of the xml files is to create a layout, which will be shown in your activity. Thus, the top level element needs to be one of the layout elements. See declaring layouts.

Mayra