【问题标题】:Custom drawable not being rendered in Xamarin StudioXamarin Studio 中未呈现自定义可绘制对象
【发布时间】:2014-11-12 12:06:02
【问题描述】:

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

【问题讨论】:

    标签: android xamarin android-drawable xamarin-studio


    【解决方案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 '<').

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-24
      • 2021-01-31
      • 2016-11-04
      • 1970-01-01
      • 2016-12-13
      • 2023-03-27
      • 2018-09-18
      • 1970-01-01
      相关资源
      最近更新 更多