我正在尝试使用 PixlUI使用 Xamarin 将自定义字体实现到我的 Android 应用程序中。我已执行以下步骤:
- 在我的主要解决方案中添加了一个新的 Android Java 绑定(bind)库
- 已添加 pixlui-1-0-5.jar到 jars 文件夹
- 在 pixlui-1-0-5.jar 的属性下,我将“include in deploy”设置为 true
- 测试了我的新 Android Java 绑定(bind)库,它构建良好,没有错误
- 在主项目下,我已将我的字体添加到 assets/fonts 文件夹
- 在引用下我添加了 pixlUI 绑定(bind)库
在我的 main.axml 中,我放置了这段代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:pixlui="http://schemas.android.com/apk/com.neopixl.pixlui" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="10dp" android:paddingRight="10dp" android:screenOrientation="portrait"> <com.neopixl.pixlui.components.textview.TextView android:id="@+id/textViewpixl" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" pixlui:copyandpaste="false" pixlui:clearclipboardcontent="true" pixlui:typeface="Lato-Light.ttf" android:layout_below="@id/btnRebate" /> </RelativeLayout>
当我构建我的项目时,它失败并出现 10 个错误,所有错误都引用“已经包含了...的定义”,pixlUI 文件中有错误 cs0102。
例如:.../pixlUI/obj/Debug/generated/src/Com.Neopixl.Pixlui.Components.Edittext.IEditTextBatchListener.cs(59,59):错误 CS0102:Com.Neopixl 类型。 Pixlui.Components.Edittext.AddNewCharEventArgs' 已经包含了一个定义
p0' (CS0102) (pixlUI)
我已尝试对此进行故障排除,但它似乎是 pixlUI 的问题或与我的解决方案中已有的内容冲突。有没有人知道如何解决这个问题?
最佳答案
首先,您应该将 pixelui.jar 的构建操作更改为 EmbeddedJar。
然后您需要将以下内容添加到绑定(bind)的 Metadata.xml 文件中:
<!-- Bindings added to rename event parameters -->
<attr path="/api/package[@name='com.neopixl.pixlui.components.edittext']/interface[@name='EditTextBatchListener']/method[@name='addNewChar']/parameter[@name='p0']" name="name">editText</attr>
<attr path="/api/package[@name='com.neopixl.pixlui.components.edittext']/interface[@name='EditTextBatchListener']/method[@name='deleteKeyboardButton']/parameter[@name='p0']" name="name">editText</attr>
<attr path="/api/package[@name='com.neopixl.pixlui.components.edittext']/interface[@name='EditTextBatchListener']/method[@name='deleteKeyboardButton']/parameter[@name='p1']" name="name">emptyText</attr>
<attr path="/api/package[@name='com.neopixl.pixlui.components.edittext']/interface[@name='EditTextFocusListener']/method[@name='loseFocus']/parameter[@name='p0']" name="name">editText</attr>
<attr path="/api/package[@name='com.neopixl.pixlui.components.edittext']/interface[@name='EditTextFocusListener']/method[@name='requestFocus']/parameter[@name='p0']" name="name">editText</attr>
重建您的绑定(bind),然后您应该能够在您的 Android 应用中使用它。
这是示例项目的屏幕截图:
关于android - 如何让 PixlUI for Android 自定义字体正常工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25388200/