Axml Designer

时间:2016-05-10 15:39:45

标签: android xamarin xamarin.android

我的xml布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="192dp"
    android:background="?attr/colorPrimaryDark"
    android:padding="16dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark"
    android:orientation="vertical"
    android:gravity="bottom">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Username"
        android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
</LinearLayout>

异常消息:

  

Bridge [resources.resolve]无法解析资源   @ style / ThemeOverlay.AppCompat.DarkBridge [resources.resolve]不能   解决资源问题   @风格/ ThemeOverlay.AppCompat.Darkjava.lang.NumberFormatException:   找不到属性'?attr / colorPrimaryDark'。你使用的是正确的吗?   主题?         在com.android.layoutlib.bridge.impl.ResourceHelper.getColor(ResourceHelper.java:76)         在com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:270)         在android.content.res.BridgeTypedArray.getDrawable(BridgeTypedArray.java:742)         在android.view.View。(View.java:3948)         在android.view.ViewGroup。(ViewGroup.java:573)         在android.widget.LinearLayout。(LinearLayout.java:203)         在android.widget.LinearLayout。(LinearLayout.java:199)         在android.widget.LinearLayout。(LinearLayout.java:195)         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)         at java.lang.reflect.Constructor.newInstance(Constructor.java:408)         在android.view.LayoutInflater.createView(LayoutInflater.java:619)         在android.view.BridgeInflater.onCreateView(BridgeInflater.java:107)         在android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)         在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)         在android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:149)         在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)         在android.view.LayoutInflater.inflate(LayoutInflater.java:492)         在android.view.LayoutInflater.inflate(LayoutInflater.java:394)         在com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:229)         在com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:426)         在com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)         在mono.android.DesignerSession.load(DesignerSession.java:170)         在mono.android.DesignerSession.processMessage(DesignerSession.java:640)         at mono.android.MessageListener.executeMessage(MessageListener.java:87)         at mono.android.MessageListener $ Runner.run(MessageListener.java:44)         在java.lang.Thread.run(Thread.java:745)       Bridge [resources.format]无法将?attr / colorPrimaryDark转换为drawableBridge [resources.resolve]无法解析资源   @ style / TextAppearance.AppCompat.Body1Bridge [resources.resolve]   无法解析资源   @风格/ TextAppearance.AppCompat.Body1java.lang.NullPointerException       mono.android.DesignerException         在mono.android.DesignerSession.load(DesignerSession.java:186)         在mono.android.DesignerSession.processMessage(DesignerSession.java:640)         at mono.android.MessageListener.executeMessage(MessageListener.java:87)         at mono.android.MessageListener $ Runner.run(MessageListener.java:44)         在java.lang.Thread.run(Thread.java:745)

我无法使用Designer,我下载了所有支持库,并且所有其他布局都显示正确,除了这个。

1 个答案:

答案 0 :(得分:0)

TextAppearance.AppCompat.Body1是样式而不是TextAppearance属性:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="192dp"
    android:background="?attr/colorPrimaryDark"
    android:padding="16dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark"
    android:orientation="vertical"
    android:gravity="bottom">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Username"
        android:style="@style/TextAppearance.AppCompat.Body1" />
</LinearLayout>