litho icon indicating copy to clipboard operation
litho copied to clipboard

shadowElevation not working

Open xSharkM opened this issue 6 years ago • 3 comments

When i use shadowElevationPx to set a row shadow like android elevation methods,but not show ,i don't know why.

The following is example code.

@LayoutSpec
public class TestSpec {
  @OnCreateLayout
 static Component onCreateLayout(ComponentContext c) {
 return Row.create(c)
        .heightPx(600)
        .alignItems(YogaAlign.CENTER)
        .justifyContent(YogaJustify.CENTER)
        .child(Row.create(c)
            .alignItems(YogaAlign.CENTER)
            .justifyContent(YogaJustify.CENTER)
            .shadowElevationPx(29)
            .heightPx(300)
            .widthPx(300)
            .backgroundColor(Color.GREEN)
            .child(SolidColor.create(c)
                .heightPx(150)
                .widthPx(150)
                .color(Color.RED))
            .build())
        .build();
 }
}

then lithoView.setComponent(Test.create(c).build());

how to set green area shadow?

xSharkM avatar May 03 '18 07:05 xSharkM

Hey @xSharkM, I am not sure that you can apply shadowElevation*() on a Component that does not support elevation at all!

pavlospt avatar May 19 '18 11:05 pavlospt

How i can use elevation(shadows)? In my app i need to create TextBlock with shadow

zibellon avatar Dec 26 '18 09:12 zibellon

you can create a Column/Row with shadow res as background like

            Column.create(c)
                .heightDip(4f)
                .widthPercent(100f)
                .backgroundRes(R.drawable.toolbar_layout_shadow)
                .build()

Wesely avatar Apr 08 '20 06:04 Wesely