问题
I am trying to use PixlUI to implement custom fonts into my Android app using Xamarin. I've followed these steps:
- 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>
When I build my project it fails with 10 errors all referencing "already contains a definition for..." with error cs0102 inside the pixlUI files.
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 for
p0' (CS0102) (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?
回答1:
First of all, you should change the Build Action for the pixelui.jar to EmbeddedJar.
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>
Rebuild your bindings then you should be able to use it in your Android app.
Here's a screenshot from the sample project:
来源:https://stackoverflow.com/questions/25388200/how-can-i-get-pixlui-for-android-custom-fonts-working