How can I get PixlUI for Android custom fonts working?

别说谁变了你拦得住时间么 提交于 2020-01-01 19:34:35

问题


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

  1. Added a new Android Java Bindings Library to my main solution
  2. Added pixlui-1-0-5.jar to the jars folder
  3. Under properties for pixlui-1-0-5.jar i've set the "include in deploy" to true
  4. Tested my new Android Java Bindings Library and it builds fine without errors
  5. Under the main project i've added my font to the assets/fonts folder
  6. Under references i've added the pixlUI binding library
  7. 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 forp0' (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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!