Adding Kerning via Hyperloop, weird behaviour #13983
-
Hi all, I'm trying to add Kening a label on Android using Hyperloop and getting some weird behaviour. I'm using Titanium Classic for this. I have a vertical Ti View with 3 labels:
When I use an Android TextView for the main header, the sub header and body copy are pushed vertically off screen. (see attached image - there should be 2 other labels below it, which display fine if I use a regular Ti Label for the header) Hyperloop Label code:
I've also tried adding an Android TextView with no Ti Label as a base and the exact same behaviour occurs, and wrapping the TextView in its own view. Setting a background colour to the TextView (as per image), the textview appears to be the right height, but some kind of margin or space is being added below it to fill the entire viewport? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 8 replies
-
Hi, can you try to use a fixed height instead of Would be also great to expost |
Beta Was this translation helpful? Give feedback.
-
Working fine here: <Alloy>
<Window>
<View height="Ti.UI.SIZE" layout="vertical">
<Label text="test test test"/>
<View id="view" width="300" height="Ti.UI.SIZE" backgroundColor="#444"/>
<Label text="test test test"/>
</View>
</Window>
</Alloy> // Creating a Titanium Label
var textLabel = Ti.UI.createLabel({
id: "mainheader",
title: "mainheader",
width: Ti.UI.FILL,
height: Ti.UI.SIZE,
textAlign: 'center',
verticalAlign: 'top',
includeFontPadding: false,
font: {
fontSize: 60,
fontWeight: "bold"
},
left: 0,
top: 20,
text: "THE HEADING TEXT (Some single line, some multiline)"
});
var TextView = require("android.widget.TextView");
// Create a Native Label, passing in the Ti.UI.Label, and adjusting the kerning
var nativeLabel = new TextView(textLabel);
nativeLabel.setLetterSpacing(-0.2);
// I believe these should position the textview as I need?
// var layoutParams = new LayoutParams(ViewGroupLayoutParams.MATCH_PARENT, ViewGroupLayoutParams.WRAP_CONTENT, Gravity.TOP);
// layoutParams.setMargins(0, 0, 0, 0);
// nativeLabel.setLayoutParams(layoutParams);
$.view.add(textLabel);
$.index.open(); so I guess it is your surrounding container. |
Beta Was this translation helpful? Give feedback.
-
I've also made a PR so it is a normal property in the SDK: #13984 |
Beta Was this translation helpful? Give feedback.
-
Done like this, the order goes wrong, so the subtitle and body copy are added first, then lastly the main heading. So you get Subtitle > Copy > Heading. In this case they all show but the problem label is at the bottom and still overspans the vertical space below it. If I add all 3 labels to the window open event, the order corrects but the subtitle and body copy pushed off screen again. It looks like the native label is either adding some kind of bottom margin that wraps to the available screen height, or creating a view itself which has a FILL property (or equivelant). Its an onboarding interstitial with the order: Main Heading (the native label) |
Beta Was this translation helpful? Give feedback.
-
Got it working, thanks for you help, greatly appreciated. Side question tho, will kerning work without attributed strings on iOS too? Or does iOS require attributed strings always? |
Beta Was this translation helpful? Give feedback.
to fix the order you can just use:
and don't add the nativeLabel
in case you don't want to use Hyperloop at all: download the ZIP from https://github.com/tidev/titanium-sdk/actions/runs/7781463918?pr=13984 (at the bottom) and use that. Then you just set
letterSpacing: -0.02
on the label.