0

在设计视图时我有一些问题,如您所见,我打开了带有视图标签的 xml 文件,但它给了我错误。这是为什么?如果我将其更改为 LinearLayout,则它会起作用。

<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
4

1 回答 1

0

我认为您不能在 xml 中创建这样的视图。xml 文件的目的是创建一个布局,该布局将显示在您的活动中。因此,顶级元素需要是布局元素之一。请参阅声明布局

于 2010-06-25T00:04:16.743 回答