android - Xamarin Studio 中未呈现自定义可绘制对象

标签 android xamarin android-drawable xamarin-studio

我正在使用自定义可绘制对象来呈现 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,因为我必须构建和部署应用程序只是为了检查一些简单的样式。这是一个已知问题吗?

最佳答案

这是一个已知问题,将在即将发布的版本(标记为 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 '<').

关于android - Xamarin Studio 中未呈现自定义可绘制对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26886610/

相关文章:

c# - 将 Xamarin 应用程序部署到设备时,Visual Studio 2015 有时会卡住

ios - WKWebView 不从特定页面加载图像

android - 可绘制资源缩放的良好实践

android - 自定义可绘制对象在应用于布局时无法正确显示

android - 使用来自服务器的数据加载本地表

android - 在android中设置和获取使用标记 fragment

c# - Xamarin 表单切换按钮在 IOS 上的默认颜色

android - 如何在 TextInputLayout android 中更改设置 EndIcon Drawable 的可见性(可见、不可见或消失)?

android - 如何将相同的样式应用于多个元素?

android - addToBackStack 不适用于 onBackPressed 方法