我怎样才能获得PixlUI为Android自定义字体工作吗?自定义、字体、工作、PixlUI

2023-09-08 08:44:09 作者:既然琴瑟起

我试图使用 PixlUI 来实现自定义字体到我Android应用使用Xamarin。我已经遵循下列步骤进行:

I am trying to use PixlUI to implement custom fonts into my Android app using Xamarin. I've followed these steps:

增加了一个新的Andr​​oid的Java库绑定到我的主要解决方案新增 pixlui-1-0 -5.jar 来的罐子文件夹在为pixlui-1-0-5.jar性能我已经设置为true 在部署中包括测试我新的Andr​​oid的Java绑定库并没有错误建立精细在主项目我已经添加了我的字体的资产/ fonts文件夹在引用我已经添加了pixlUI绑定库

在我main.axml我已经放在这个code: Added a new Android Java Bindings Library to my main solution Added pixlui-1-0-5.jar to the jars folder Under properties for pixlui-1-0-5.jar i've set the "include in deploy" to true Tested my new Android Java Bindings Library and it builds fine without errors Under the main project i've added my font to the assets/fonts folder Under references i've added the pixlUI binding library

In my main.axml i've placed this code:

<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。

When I build my project it fails with 10 errors all referencing "already contains a definition for..." with error cs0102 inside the pixlUI files.

例如: .../pixlUI/obj/Debug/generated/src/Com.Neopixl.Pixlui.Components.Edittext.IEditTextBatchListener.cs(59,59):错误CS0102:类型 Com.Neopixl.Pixlui.Components.Edittext.AddNewCharEventArgs'已经包含了一个定义 P0'(CS0102)(pixlUI)

Ex: .../pixlUI/obj/Debug/generated/src/Com.Neopixl.Pixlui.Components.Edittext.IEditTextBatchListener.cs(59,59): Error CS0102: The type Com.Neopixl.Pixlui.Components.Edittext.AddNewCharEventArgs' already contains a definition forp0' (CS0102) (pixlUI)

我试图解决此,但它似乎是要么pixlUI的问题,或在我的解决方案已经事冲突。有没有人对如何解决这个想法?

I've tried troubleshooting this but it appears to be either an issue with pixlUI or conflict with something already in my solution. Does anyone have an idea on how to solve this?

推荐答案

首先,你应该更改pixelui.jar到的 EmbeddedJar 的生成操作。

First of all, you should change the Build Action for the pixelui.jar to EmbeddedJar.

然后,你需要将以下添加到您绑定的的 metadata.xml中的文件:

Then you need to add the following to your binding's Metadata.xml file:

<!-- 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>

重建你的绑定,那么你应该能够在Android应用中使用它。

Rebuild your bindings then you should be able to use it in your Android app.

下面是从样本项目中的截图:

Here's a screenshot from the sample project: