shamanland / fonticon Goto Github PK
View Code? Open in Web Editor NEWAndroid implementation of font-based icons.
Home Page: http://blog.shamanland.com/p/android-fonticon-library.html
Android implementation of font-based icons.
Home Page: http://blog.shamanland.com/p/android-fonticon-library.html
Hi Sir,
I am getting this Error:(710) Attribute "textSize" already defined with incompatible format. when i compile my files and i am using latest build compile 'com.shamanland:fonticon:0.1.9' please help me how to sort it out
Just by adding the dependency to build.gradle
, I'm getting this during :app:dexDebug
:
[...]
:app:packageAllDebugClassesForMultiDex
:app:shrinkDebugMultiDexComponents
:app:createDebugMainDexClassList
:app:dexDebug
AGPBI: {"kind":"SIMPLE","text":"UNEXPECTED TOP-LEVEL ERROR:","position":{},"original":"UNEXPECTED TOP-LEVEL ERROR:"}
AGPBI: {"kind":"SIMPLE","text":"java.lang.OutOfMemoryError: Java heap space","position":{},"original":"java.lang.OutOfMemoryError: Java heap space"}
AGPBI: {"kind":"SIMPLE","text":"\tat java.util.BitSet.initWords(BitSet.java:164)","position":{},"original":"\tat java.util.BitSet.initWords(BitSet.java:164)"}
AGPBI: {"kind":"SIMPLE","text":"\tat java.util.BitSet.\u003cinit\u003e(BitSet.java:159)","position":{},"original":"\tat java.util.BitSet.\u003cinit\u003e(BitSet.java:159)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.ssa.SsaMethod.bitSetFromLabelList(SsaMethod.java:137)","position":{},"original":"\tat com.android.dx.ssa.SsaMethod.bitSetFromLabelList(SsaMethod.java:137)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.ssa.SsaBasicBlock.newFromRop(SsaBasicBlock.java:161)","position":{},"original":"\tat com.android.dx.ssa.SsaBasicBlock.newFromRop(SsaBasicBlock.java:161)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.ssa.SsaMethod.convertRopToSsaBlocks(SsaMethod.java:173)","position":{},"original":"\tat com.android.dx.ssa.SsaMethod.convertRopToSsaBlocks(SsaMethod.java:173)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.ssa.SsaMethod.newFromRopMethod(SsaMethod.java:103)","position":{},"original":"\tat com.android.dx.ssa.SsaMethod.newFromRopMethod(SsaMethod.java:103)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.ssa.SsaConverter.convertToSsaMethod(SsaConverter.java:44)","position":{},"original":"\tat com.android.dx.ssa.SsaConverter.convertToSsaMethod(SsaConverter.java:44)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.ssa.Optimizer.optimize(Optimizer.java:98)","position":{},"original":"\tat com.android.dx.ssa.Optimizer.optimize(Optimizer.java:98)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.ssa.Optimizer.optimize(Optimizer.java:72)","position":{},"original":"\tat com.android.dx.ssa.Optimizer.optimize(Optimizer.java:72)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:297)","position":{},"original":"\tat com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:297)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137)","position":{},"original":"\tat com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93)","position":{},"original":"\tat com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.processClass(Main.java:729)","position":{},"original":"\tat com.android.dx.command.dexer.Main.processClass(Main.java:729)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)","position":{},"original":"\tat com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.access$300(Main.java:83)","position":{},"original":"\tat com.android.dx.command.dexer.Main.access$300(Main.java:83)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)","position":{},"original":"\tat com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)","position":{},"original":"\tat com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)","position":{},"original":"\tat com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)","position":{},"original":"\tat com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.processOne(Main.java:632)","position":{},"original":"\tat com.android.dx.command.dexer.Main.processOne(Main.java:632)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.processAllFiles(Main.java:505)","position":{},"original":"\tat com.android.dx.command.dexer.Main.processAllFiles(Main.java:505)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.runMultiDex(Main.java:334)","position":{},"original":"\tat com.android.dx.command.dexer.Main.runMultiDex(Main.java:334)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.run(Main.java:244)","position":{},"original":"\tat com.android.dx.command.dexer.Main.run(Main.java:244)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.main(Main.java:215)","position":{},"original":"\tat com.android.dx.command.dexer.Main.main(Main.java:215)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.Main.main(Main.java:106)","position":{},"original":"\tat com.android.dx.command.Main.main(Main.java:106)"}
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_25\bin\java.exe'' finished with non-zero exit value 3
Rings a bell?
I was wondering why my builds are always slow.. it turns out that whenever gradle attempts to fetch a new dep from my repos, it hangs on shamanland every time it checks there instead of just skipping past it... any idea why this happens or how to fix it?
i found this issue on huawei,lenovo and samsung old devices , all having os which is around 4.3 android
Hi, is there a way to preview the fonticons in the Android Studio layout preview?
FontIconDrawable
already supports this feature, need to implement for FontIconView
.
If I want to composite two icons together with different colors and sizes, is it possible to create a single drawable with the current implementation?
If attributes defined as ?attr
, then crash occurred
<?xml version="1.0" encoding="utf-8"?>
<font-icon
xmlns:app="http://schemas.android.com/apk/res-auto"
app:text="@string/ic_scaleup"
app:textSize="?android:attr/actionBarSize"
app:textColor="?android:attr/textColorPrimary"
/>
Caused by: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x2/d=0x1010036 a=-1}
at android.content.res.Resources.loadColorStateList(Resources.java:1804)
at android.content.res.TypedArray.getColorStateList(TypedArray.java:342)
at com.shamanland.fonticon.FontIconDrawable.inflate(FontIconDrawable.java:101)
at com.shamanland.fonticon.FontIconDrawable.inflate(FontIconDrawable.java:57)
at com.shamanland.fonticon.CompoundDrawables.inflateDrawables(CompoundDrawables.java:61)
at com.shamanland.fonticon.CompoundDrawables.initCompoundDrawables(CompoundDrawables.java:81)
at com.shamanland.fonticon.CompoundDrawables.init(CompoundDrawables.java:44)
at com.shamanland.fonticon.FontIconTextView.<init>(FontIconTextView.java:18)
... 28 more
It looks like the actual source for the library isn't checked in, is that intentional?
I've had a look at the code and I've seen no way to do this. It seems that the FontIconDrawable is immutable after inflating from the XML and there's no way to create it programatically either.
In my app, I'd like to make it possible for the user to select one icon and one color. So, it would be saved and used later. Is it possible now? If no, is there any plans to make it possible?
We are getting UnsupportedOperationException on projects running on Java 1.8. We get that on following call :
FontIconDrawable.inflate(this, drawable (R.xml.ic_cross))
Please fix this issue. Please let me know in case anything else is required.
This just shows the character "j" instead of the icon..
<com.shamanland.fonticon.FontIconView
android:id="@+id/filter_button"
android:text="@string/icon_filter"
android:textColor="@color/blue"
android:textSize="@dimen/text_x_large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
but if I do this
<ImageView
android:id="@+id/filter_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
and have this xml
<font-icon
xmlns:android="http://schemas.android.com/apk/res-auto"
android:text="@string/icon_filter"
android:textSize="@dimen/text_x_large"
android:textColor="@color/blue"
/>
and this code
Drawable icon = FontIconDrawable.inflate(activity.getResources(), R.xml.ic_btn_filter);
filterButton.setImageDrawable(icon);
I see the icon as expected.
Am I missing something obvious to get the first one to work? I'd like to convert everything over to your awesome library where possible, but I don't want to deal with every usage in code if I can help it.
I have FontIconEditText and standard Edit Text above one another and the margins for the icon in the FontIcon edit text are non-existent. Text touches the icon so it looks different to the standard edit text control.
Maybe I missed something?
I would like to use a font icon for the overflow dots in my action bar. As far as I can tell, the only way to do this is to set a style that points at a drawable:
<style name="OverFlow" parent="@android:style/Widget.Holo.ActionButton.Overflow" tools:ignore="NewApi">
<item name="android:src">@drawable/overflow_icon</item>
</style>
Perhaps this would be an inspiration for how to do it:
https://code.google.com/p/adet/
I will play around when I have some time.
We have been using this library in the app since gradle 2.3.3 but in last update to gradle 3.1.3, FontIconTextView is broken. The project compiles fine without any warnings but when trying to load the screen, get an exception as
android.view.InflateException: Binary XML file line #161: Error inflating class com.shamanland.fonticon.FontIconTextView
at android.view.LayoutInflater.createView(LayoutInflater.java:637)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:747)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:810)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:920)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.inflate(LayoutInflater.java:508)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.ogd.biz.views.fragments.AllItemsFragmentNew.onCreateItem(AllItemsFragmentNew.java:386)
at com.ogd.biz.views.adapters.SectionWiseItemAdapter$1.onClick(SectionWiseItemAdapter.java:189)
at android.view.View.performClick(View.java:5047)
at android.view.View$PerformClick.run(View.java:20286)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5491)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:984)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:611)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:747)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:810)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:920)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.inflate(LayoutInflater.java:508)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.ogd.biz.views.fragments.AllItemsFragmentNew.onCreateItem(AllItemsFragmentNew.java:386)
at com.ogd.biz.views.adapters.SectionWiseItemAdapter$1.onClick(SectionWiseItemAdapter.java:189)
at android.view.View.performClick(View.java:5047)
at android.view.View$PerformClick.run(View.java:20286)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5491)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:984)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x3
at android.content.res.TypedArray.getDimension(TypedArray.java:497)
at com.shamanland.fonticon.FontIconDrawable.inflate(FontIconDrawable.java:111)
at com.shamanland.fonticon.FontIconDrawable.inflate(FontIconDrawable.java:65)
at com.shamanland.fonticon.CompoundDrawables.inflateDrawables(CompoundDrawables.java:61)
at com.shamanland.fonticon.CompoundDrawables.initCompoundDrawables(CompoundDrawables.java:81)
at com.shamanland.fonticon.CompoundDrawables.init(CompoundDrawables.java:44)
at com.shamanland.fonticon.FontIconTextView.(FontIconTextView.java:18)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:611)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:747)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:810)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:920)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.inflate(LayoutInflater.java:508)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.ogd.biz.views.fragments.AllItemsFragmentNew.onCreateItem(AllItemsFragmentNew.java:386)
at com.ogd.biz.views.adapters.SectionWiseItemAdapter$1.onClick(SectionWiseItemAdapter.java:189)
at android.view.View.performClick(View.java:5047)
at android.view.View$PerformClick.run(View.java:20286)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5491)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:984)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
I believe the line causing the issue is:
mTextSize = a.getDimension(R.styleable.FontIconDrawable_textSize, 9f);
Can anyone suggest a quick fix for this?
Quote from Drawable documentation:
The setBounds(Rect) method must be called to tell the Drawable where it is drawn and how large it should be. All Drawables should respect the requested size, often simply by scaling their imagery. A client can find the preferred size for some Drawables with the getIntrinsicHeight() and getIntrinsicWidth() methods.
But current updatePaint
implementation ignores the requested bounds. This leads to issues like this:
I am using calligraphy library so added following lines in Activity class, font icons are not visible after adding this,
@OverRide
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
I got this error:
Caused by: java.lang.ClassCastException:
at com.shamanland.fonticon.FontIconView.onRestoreInstanceState(FontIconView.java:224)
I'm sorry, but I can't give more info about this error.
Need to add xml-attrs like a 'iconStart' and 'iconEnd', and anything else which is necessary to correctly support RTL layout.
I'm trying to dynamically change the font color using the following code. It's not working. Does anyone know how to change the color?
ImageView icon = FontIconDrawable.inflate(context, R.xml.arrow);
icon.setTextColor(R.color.green);
Steps:
attr
resource for color.<font-icon>
drawable: app:textColor="?attr/custom_color"
Expected result:
FontIconDrawable
should be inflated
Actual result:
Caused by: java.lang.RuntimeException: Failed to resolve attribute at index 1
at android.content.res.TypedArray.getColorStateList(TypedArray.java:425)
at com.shamanland.fonticon.FontIconDrawable.inflate(FontIconDrawable.java:106)
at com.shamanland.fonticon.FontIconDrawable.inflate(FontIconDrawable.java:65)
at com.shamanland.fonticon.CompoundDrawables.inflateDrawables(CompoundDrawables.java:61)
at com.shamanland.fonticon.CompoundDrawables.initCompoundDrawables(CompoundDrawables.java:81)
at com.shamanland.fonticon.CompoundDrawables.init(CompoundDrawables.java:44)
at com.shamanland.fonticon.FontIconTextView.<init>(FontIconTextView.java:18)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.