litho
litho copied to clipboard
Component is forced to resize when using paddingDip() on its parent
Seems like the padding isn't respecting the size of its child component. Please see the screenshot.
Code
@LayoutSpec
object LithoPageComponentSpec {
@OnCreateLayout
fun onCreateLayout(c: ComponentContext): Component {
return Column.create(c)
.heightPercent(100f)
.paddingDip(YogaEdge.TOP, 50f)
.child(Row.create(c)
.widthPercent(100f)
.child(
Text.create(c)
.text("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam")
.textSizeDip(17f)
.isSingleLine(true)
.ellipsize(TextUtils.TruncateAt.END)
.customEllipsisText("...")
.border(Border.create(c)
.widthDip(YogaEdge.ALL, 1f)
.color(YogaEdge.ALL, Color.MAGENTA)
.build())
.build()
)
.child(Row.create(c)
.border(Border.create(c)
.widthDip(YogaEdge.ALL, 1f)
.color(YogaEdge.ALL, Color.BLUE)
.build())
.paddingDip(YogaEdge.HORIZONTAL, 25f) // This line caused the issue
.child(Image.create(c)
.widthDip(24f)
.heightDip(24f)
.border(Border.create(c)
.widthDip(YogaEdge.ALL, 1f)
.color(YogaEdge.ALL, Color.RED)
.build())
.drawableRes(R.mipmap.ic_launcher)
.scaleType(ImageView.ScaleType.FIT_XY)
.build())
.build())
.build())
.build()
}
}
Dependencies
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// Litho Dependencies Start
implementation "com.facebook.litho:litho-core:0.31.0"
implementation "com.facebook.litho:litho-widget:0.31.0"
implementation "com.facebook.litho:litho-annotations:0.31.0"
kapt "com.facebook.litho:litho-processor:0.31.0"
// SoLoader
implementation "com.facebook.soloader:soloader:0.6.0"
// Litho Sections Dependencies Start
implementation "com.facebook.litho:litho-sections-core:0.31.0"
implementation "com.facebook.litho:litho-sections-widget:0.31.0"
implementation "com.facebook.litho:litho-sections-annotations:0.31.0"
kapt "com.facebook.litho:litho-sections-processor:0.31.0"
}
I think this is the expected behaviour. Checkout this YogaPlayground to see how Yoga layouts the above flex containers.
Could you maybe share what you expect instead or maybe what is the layout you want to achieve?
Closing this, please reopen to raise us again 🤙