自定义绘图不在Xamarin Studio中呈现

时间:2014-11-12 12:06:03

标签: android xamarin android-drawable xamarin-studio

我使用自定义drawable渲染Android TextView周围的边框。

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:bottom="1dp" android:left="-2dp" android:right="-2dp" android:top="-10dp">
        <shape android:shape="rectangle" >
            <stroke android:width="1dp" android:color="@color/pale_grey" />
            <solid android:color="#00FFFFFF" />
            <padding android:left="24dp" android:right="24dp"
                android:top="12dp" android:bottom="12dp" />
        </shape>
    </item>
</layer-list>

这在运行时可以正常工作,但在查看具有应用了该背景的TextView的Activity时,不会在Xamarin Studio Designer(或Visual Studio中的设计器)中呈现。

<TextView
    android:id="@+id/txtHeightSelection"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:textSize="@dimen/text_size_large"
    android:text="Height"
    android:textStyle="bold"
    android:textColor="#1f2233"
    android:background="@drawable/customborder2"
    local:MvxBind="Click AddEntryCommand, CommandParameter='Height'" />

毫无疑问,这是一个PITA,因为我必须构建和部署应用程序只是为了检查一些简单的样式。这是一个已知的问题吗?

1 个答案:

答案 0 :(得分:1)

这是一个已知问题,即将发布的版本(标记为5.7):

作为一种解决方法,在十六进制编辑器(包含在Xamarin Studio中)中打开可绘制文件,如果它们是这个序列,则删除前三个字节:EF BB BF

来自Bugzilla:

The issue comes from the fact that our Android rendering process doesn't like the UTF-8 BOM sequence we forcefully add to XML files in some places.

A simple workaround is to open the drawable XML files in an editor that doesn't write a BOM and re-save the file from there. You can also open it up in an hexadecimal editor and remove the first three bytes of the file (before the initial '<').