We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
master
Apply .alignItems(YogaAlign.BASELINE) on a row with 2 Text as child; where one of the Texts have a line break to force two lines.
The two Text are bottom aligned based off the view bottom, rather than baseline aligned:
It seems that TextSpec is not using onMeasureBaseline for baseline calculation: (https://github.com/facebook/litho/blob/master/litho-widget/src/main/java/com/facebook/litho/widget/TextSpec.java)
Also, Android LinearLayout should be using baseline alignment as default behavior: https://possiblemobile.com/2013/10/shifty-baseline-alignment/
Two texts be baseline aligned:
package com.facebook.samples.litho.playground;
import android.graphics.Color;
import com.facebook.litho.Component; import com.facebook.litho.ComponentContext; import com.facebook.litho.Row; import com.facebook.litho.annotations.LayoutSpec; import com.facebook.litho.annotations.OnCreateLayout; import com.facebook.litho.widget.Text; import com.facebook.yoga.YogaAlign;
@LayoutSpec public class PlaygroundComponentSpec {
@OnCreateLayout static Component onCreateLayout(ComponentContext c) { return Row.create(c) .alignItems(YogaAlign.BASELINE) .child( Text.create(c) .textSizeDip(15) .text("15Test\n asdfg") .backgroundColor(Color.GRAY) .build()) .child(Text.create(c).textSizeDip(24).text("24Test").backgroundColor(Color.YELLOW).build()) .build(); }
The text was updated successfully, but these errors were encountered:
@dsyang Is that the same behaviour you observed?
Sorry, something went wrong.
No branches or pull requests
Version
master
Issues and Steps to Reproduce
Apply .alignItems(YogaAlign.BASELINE) on a row with 2 Text as child; where one of the Texts have a line break to force two lines.
The two Text are bottom aligned based off the view bottom, rather than baseline aligned:
It seems that TextSpec is not using onMeasureBaseline for baseline calculation: (https://github.com/facebook/litho/blob/master/litho-widget/src/main/java/com/facebook/litho/widget/TextSpec.java)
Also, Android LinearLayout should be using baseline alignment as default behavior: https://possiblemobile.com/2013/10/shifty-baseline-alignment/
Expected Behavior
Two texts be baseline aligned:
Link to Code
package com.facebook.samples.litho.playground;
import android.graphics.Color;
import com.facebook.litho.Component;
import com.facebook.litho.ComponentContext;
import com.facebook.litho.Row;
import com.facebook.litho.annotations.LayoutSpec;
import com.facebook.litho.annotations.OnCreateLayout;
import com.facebook.litho.widget.Text;
import com.facebook.yoga.YogaAlign;
@LayoutSpec
public class PlaygroundComponentSpec {
@OnCreateLayout
static Component onCreateLayout(ComponentContext c) {
return Row.create(c)
.alignItems(YogaAlign.BASELINE)
.child(
Text.create(c)
.textSizeDip(15)
.text("15Test\n asdfg")
.backgroundColor(Color.GRAY)
.build())
.child(Text.create(c).textSizeDip(24).text("24Test").backgroundColor(Color.YELLOW).build())
.build();
}
The text was updated successfully, but these errors were encountered: