Html labels LLXperiment
Html labels LLXperiment
While I were searching, I suddenly went to a page about how to make a multi-color TextView.
And I though…hey, this should be possible to do in LL.
Yes it was.
This is a way (not the best one I guess, but reliable) to have Html labels in LL.
The script is very simple: it searches for the label view of an item, it converts its LL’s label using Html.fromHtml() and change the TexView with that value. The result is a custom label with colors, sizes, and more [IMPORTANT! not all is available, but I don’t know what is and what is not, so try]
If you set the script in the resumed event of the item, you will have it permanently. (Note: if you change the label you need to switch to another app, then back to LL for the script to run and change the new label, or simply run it manually from the item menu)
Another thing to note: I found that the LL item setting “Maximum number of lines” cuts the label or forces it to be one-line (when it is 1). Keep this in mind.
Some label examples are:
Red and blue
italic bold
Lightning launcher
html labelsPierre Hébert … Maybe a setting ‘html label’ in shortcuts under text? :3
]]>
< ![CDATA[
LL.bindClass(“android.text.Html”);
LL.bindClass(“android.view.ViewGroup”);
var item=LL.getEvent().getItem();
if(!findTextView(item.getRootView())){
Android.makeNewToast(“Label’s TextView of the item “+item+” couldn’t be found”,false).show();
}
function findTextView(v){
if(v.class.toString()==”class net.pierrox.lightning_launcher.views.aq“){
v.setText(Html.fromHtml(item.getLabel()));
return true;
}
if(v instanceof ViewGroup){
var count=v.getChildCount();
for(var t=0;t
if(findTextView(v.getChildAt(t)))return true;
}
}
return false;
}
]]>
< ![CDATA[
TrianguloY it has been discussed in the past and I almost thought it was implemented by auto detecting html in the label content…
Tip: since the class name “…views.aq” may change from a build to another, you may search for the view using isInstance(android.widget.TextView)
]]>
< ![CDATA[
Pierre Hébert does that means that it is implemented some way? How?
(Thanks for the class search, I should have used that but…well I took the easy way 😛 )
Aand, while writing this comment a pop-up appear ‘update in lightning change log’
That was fast!
]]>
< ![CDATA[
I just implemented this (It will be in the next beta). I thought I already done it, I recall a discussion with +Thomas Greer about this, but no.
I skipped the new option in text settings by lazily looking at the first character: if it contains a ‘< ' then try to decode html first.
]]>
< ![CDATA[
Is it posible by HTML set different font from device?
]]>
< ![CDATA[
wow, tag
working…
]]>
< ![CDATA[
No, typeface cannot be loaded from this html, nor images, although there is a way to handle them. The difficult thing is how to name images.
]]>
< ![CDATA[
And in future by different way? For me is very importem set different typeface (ariel, tahoma, verdana, etc)
]]>
< ![CDATA[
I think technically this is possible, but you know that I am progressing slowly…
]]>