dwarvesf / til

Today I Learned. Our knowledge hub. List out what we've learned everyday, organized.
29 stars 1 forks source link

Bottom sheet behavior half expended and full expended #52

Open siliconprime-thanhduc opened 5 years ago

siliconprime-thanhduc commented 5 years ago

Khi ta implement Bottom sheet, trạng thái mặc định sẽ là full expended, vậy làm sao để có thêm state half expended khi ta swipe lên lần 1 và sẽ full khi swipe tiếp.

Ta cần thiết lập behavior_fitToContents và behavior_halfExpandedRatio

behavior_fitToContents: Determines whether or not the height of the expanded sheet wraps its contents. Alternatively, it expands in two stages: half the height of the parent container, full height of the parent container. The default value is true.

behavior_halfExpandedRatio: Determines the height of the sheet (as a ratio of the parent container height) when in half-expanded state. This has no effect if behavior_fitToContents is not set to false and should be greater than the peek height. The default value is 0.5 (the recommended ratio in the Material Guidelines).

eg: behavior_fitToContents ta set false behavior_halfExpandedRatio là 0.5

vậy khi width ==500 thì trạng thái đầu tiên khi half expanded width sẽ là 250, trang thái full sẽ là 500