我正在使用自定义可绘制对象来呈现 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/