How to set up floating action button expansion direction in Android Studio?


I try to give to a height of floating action button a set of constraints, that will look like "bottom of button is 8dp from bottom of screen, top of button is 92% of screen size from top of screen, but, if button height (according to previous constraints) become lower than 40dp, expand button in top direction to achieve this height". I’ve almost done this successfully, but, when button starts to expand to achieve 40dp height, it expands in both directions – top and bottom – and I can’t restrict it expansion to only top direction. Are there any ways to do what I want to do? Also, I have more global question – are there any ways to give to one constraint higher priority, than to another?

Code of button:


    app:layout_constraintTop_toTopOf="@+id/guideline13" />

Screenshot 1: Button is 8dp from bottom of screen, 92% from top of screen, everything is fine!

Screenshot 2: I change screen orientation, so button becomes too small, it adjusts to minimal height constraint – and expands in both directions instead of expanding in top direction, moving offscreen.


I found answer myself. Adding app:layout_constraintVertical_bias="0.8" in code helped me, may be it will help someone else!

Answered By – Denis Sonozaki

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published