How to put Floating Action Button in the bottom of the screen with Collapsing ToolBar to be always visible
up vote
0
down vote
favorite
I have fragment with floating action button inside activity with collapsing toolbar. When toolbar is collapsed everything is ok, but when it's expended, FAB is not visible (it's below the screen).
Here is xml of my fragment with FAB:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/layout">
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="@+id/layout"
app:layout_anchorGravity="bottom|right|end"
/>
</android.support.design.widget.CoordinatorLayout>
add a comment |
up vote
0
down vote
favorite
I have fragment with floating action button inside activity with collapsing toolbar. When toolbar is collapsed everything is ok, but when it's expended, FAB is not visible (it's below the screen).
Here is xml of my fragment with FAB:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/layout">
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="@+id/layout"
app:layout_anchorGravity="bottom|right|end"
/>
</android.support.design.widget.CoordinatorLayout>
1
you can try removing line app:layout_anchor="@+id/layout"
– ahuja007
Nov 21 at 5:57
It doesn't work. Now FAB is in top-left of the layout
– Jacek
Nov 21 at 6:03
where is the code for toolbar, are your toolbar and fab in different xml?
– Karan Mer
Nov 21 at 6:14
also it would be better if you use recyclerview in place of listview.
– Karan Mer
Nov 21 at 6:14
Yes, i will change listview to recyclerview. Toolbar is in activity's xml, this is fragment's xml
– Jacek
Nov 21 at 6:21
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have fragment with floating action button inside activity with collapsing toolbar. When toolbar is collapsed everything is ok, but when it's expended, FAB is not visible (it's below the screen).
Here is xml of my fragment with FAB:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/layout">
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="@+id/layout"
app:layout_anchorGravity="bottom|right|end"
/>
</android.support.design.widget.CoordinatorLayout>
I have fragment with floating action button inside activity with collapsing toolbar. When toolbar is collapsed everything is ok, but when it's expended, FAB is not visible (it's below the screen).
Here is xml of my fragment with FAB:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/layout">
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="@+id/layout"
app:layout_anchorGravity="bottom|right|end"
/>
</android.support.design.widget.CoordinatorLayout>
asked Nov 21 at 5:42
Jacek
33
33
1
you can try removing line app:layout_anchor="@+id/layout"
– ahuja007
Nov 21 at 5:57
It doesn't work. Now FAB is in top-left of the layout
– Jacek
Nov 21 at 6:03
where is the code for toolbar, are your toolbar and fab in different xml?
– Karan Mer
Nov 21 at 6:14
also it would be better if you use recyclerview in place of listview.
– Karan Mer
Nov 21 at 6:14
Yes, i will change listview to recyclerview. Toolbar is in activity's xml, this is fragment's xml
– Jacek
Nov 21 at 6:21
add a comment |
1
you can try removing line app:layout_anchor="@+id/layout"
– ahuja007
Nov 21 at 5:57
It doesn't work. Now FAB is in top-left of the layout
– Jacek
Nov 21 at 6:03
where is the code for toolbar, are your toolbar and fab in different xml?
– Karan Mer
Nov 21 at 6:14
also it would be better if you use recyclerview in place of listview.
– Karan Mer
Nov 21 at 6:14
Yes, i will change listview to recyclerview. Toolbar is in activity's xml, this is fragment's xml
– Jacek
Nov 21 at 6:21
1
1
you can try removing line app:layout_anchor="@+id/layout"
– ahuja007
Nov 21 at 5:57
you can try removing line app:layout_anchor="@+id/layout"
– ahuja007
Nov 21 at 5:57
It doesn't work. Now FAB is in top-left of the layout
– Jacek
Nov 21 at 6:03
It doesn't work. Now FAB is in top-left of the layout
– Jacek
Nov 21 at 6:03
where is the code for toolbar, are your toolbar and fab in different xml?
– Karan Mer
Nov 21 at 6:14
where is the code for toolbar, are your toolbar and fab in different xml?
– Karan Mer
Nov 21 at 6:14
also it would be better if you use recyclerview in place of listview.
– Karan Mer
Nov 21 at 6:14
also it would be better if you use recyclerview in place of listview.
– Karan Mer
Nov 21 at 6:14
Yes, i will change listview to recyclerview. Toolbar is in activity's xml, this is fragment's xml
– Jacek
Nov 21 at 6:21
Yes, i will change listview to recyclerview. Toolbar is in activity's xml, this is fragment's xml
– Jacek
Nov 21 at 6:21
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
replace
app:layout_anchor="@+id/layout"
app:layout_anchorGravity="bottom|right|end"
with
android:layout_gravity="bottom|end"
This should work
No, it doesn't work with collapsing toolbar. I have an idea to put FAB to activity xml. I will try it
– Jacek
Nov 21 at 6:14
Yeah please try
– ahuja007
Nov 21 at 6:36
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
replace
app:layout_anchor="@+id/layout"
app:layout_anchorGravity="bottom|right|end"
with
android:layout_gravity="bottom|end"
This should work
No, it doesn't work with collapsing toolbar. I have an idea to put FAB to activity xml. I will try it
– Jacek
Nov 21 at 6:14
Yeah please try
– ahuja007
Nov 21 at 6:36
add a comment |
up vote
0
down vote
replace
app:layout_anchor="@+id/layout"
app:layout_anchorGravity="bottom|right|end"
with
android:layout_gravity="bottom|end"
This should work
No, it doesn't work with collapsing toolbar. I have an idea to put FAB to activity xml. I will try it
– Jacek
Nov 21 at 6:14
Yeah please try
– ahuja007
Nov 21 at 6:36
add a comment |
up vote
0
down vote
up vote
0
down vote
replace
app:layout_anchor="@+id/layout"
app:layout_anchorGravity="bottom|right|end"
with
android:layout_gravity="bottom|end"
This should work
replace
app:layout_anchor="@+id/layout"
app:layout_anchorGravity="bottom|right|end"
with
android:layout_gravity="bottom|end"
This should work
answered Nov 21 at 6:09
ahuja007
21119
21119
No, it doesn't work with collapsing toolbar. I have an idea to put FAB to activity xml. I will try it
– Jacek
Nov 21 at 6:14
Yeah please try
– ahuja007
Nov 21 at 6:36
add a comment |
No, it doesn't work with collapsing toolbar. I have an idea to put FAB to activity xml. I will try it
– Jacek
Nov 21 at 6:14
Yeah please try
– ahuja007
Nov 21 at 6:36
No, it doesn't work with collapsing toolbar. I have an idea to put FAB to activity xml. I will try it
– Jacek
Nov 21 at 6:14
No, it doesn't work with collapsing toolbar. I have an idea to put FAB to activity xml. I will try it
– Jacek
Nov 21 at 6:14
Yeah please try
– ahuja007
Nov 21 at 6:36
Yeah please try
– ahuja007
Nov 21 at 6:36
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405879%2fhow-to-put-floating-action-button-in-the-bottom-of-the-screen-with-collapsing-to%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
you can try removing line app:layout_anchor="@+id/layout"
– ahuja007
Nov 21 at 5:57
It doesn't work. Now FAB is in top-left of the layout
– Jacek
Nov 21 at 6:03
where is the code for toolbar, are your toolbar and fab in different xml?
– Karan Mer
Nov 21 at 6:14
also it would be better if you use recyclerview in place of listview.
– Karan Mer
Nov 21 at 6:14
Yes, i will change listview to recyclerview. Toolbar is in activity's xml, this is fragment's xml
– Jacek
Nov 21 at 6:21