ExpandableCardView icon indicating copy to clipboard operation
ExpandableCardView copied to clipboard

StartExpanded doesn't work

Open ShawnTheBeachy opened this issue 6 years ago • 4 comments

If startExpanded is set to true the CardView starts expanded, but when tapped it disappears completely.

ShawnTheBeachy avatar Sep 01 '18 03:09 ShawnTheBeachy

The card disappears because the card height is 0. When the card expands, in expand() method, the line: final int initialHeight = card.getHeight(); gives the card height as 0. When the card collapses, since it's initial height is 0, it does not shows.

To fix this, you can give some delay(10 milli sec) and then expand the card.

shubham08gupta avatar Oct 08 '18 09:10 shubham08gupta

@shubham171294 can you explain how that delay works, please?

joseRelvasF3m avatar Jan 11 '19 11:01 joseRelvasF3m

new Handler().postDelayed(new Runnable() { @Override public void run() { card.setExpanded(true); } }, 10);

The delay works because when the system is inflating the layout, the card is not yet expanded. So we give some delay so that the layout is inflated first and then the card is expanded. If we don't give the delay, at layout calculation time the height comes out to be 0.

shubham08gupta avatar Jan 12 '19 06:01 shubham08gupta

new Handler().postDelayed(new Runnable() { @Override public void run() { card.setExpanded(true); } }, 10);

The delay works because when the system is inflating the layout, the card is not yet expanded. So we give some delay so that the layout is inflated first and then the card is expanded. If we don't give the delay, at layout calculation time the height comes out to be 0.

Doesn't work

shahzad1 avatar Mar 03 '21 06:03 shahzad1