我有一个可以膨胀的RelativeLayout.我想在顶部添加一个跨越布局宽度的纯色矩形.我尝试将以下内容放入我的xml中:
<view android:id="@+id/top_alert"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_above="@+id/orders_gridview"
android:layout_alignParentTop="true"
android:background="@color/table_request_assistance"
android:visibility="visible"/>
Run Code Online (Sandbox Code Playgroud)
现在,当我尝试给我的布局充气时,我在LayoutInflater.createViewFromTag上得到一个NullPointerException(第715行):
if (name.equals(TAG_1995)) {
Run Code Online (Sandbox Code Playgroud)
name 如此设置:
if (name.equals("view")) {
name = attrs.getAttributeValue(null, "class");
}
Run Code Online (Sandbox Code Playgroud)
显然没有"类"属性.我该如何添加?我在http://schemas.android.com/apk/res/android中找不到任何结果.我应该加吗?这是标准的方法吗?它似乎应该是世界上最简单的东西.