markormesher / android-fab

Floating action button (FAB) for Android with speed-dial menu functionality
Apache License 2.0
211 stars 29 forks source link

Content cover and padding/margin #37

Closed Yakow13 closed 6 years ago

Yakow13 commented 6 years ago

When using padding for FAB component, to trim its position in layout, after expanding the content cover, it's not filling the whole area. I'm not sure if this is bug, or expected behavior.

For more info, check the screenshot. The area on left is covered, the area on right is not. FAB is in the layout which is covering whole screen

screenshot_20180821-110102 1

markormesher commented 6 years ago

Hi @Yakow13 - thanks for raising this issue.

The content cover is implemented as a circle shape that is centred on the FAB and expands when required. Until recently it expanded to a fixed, arbitrarily large size that worked on most devices, but as of v2.3.1 the circle is sized so that the radius is equal to the diagonal width of the screen. That size should work for your purpose, assuming the FAB is sitting above everything else in your layout.

Can you try with the latest version of the library, and also try setting a coloured content cover to more clearly show which area it is covering? Thanks.

Yakow13 commented 6 years ago

I'm working with newest version, v2.3.1.

Here is screenshot how does it looks like with following parameters: android:layout_width="match_parent" android:layout_height="match_parent" android:paddingEnd="630dp"

Am I doing something wrong, or content cover is not designed to work with padding?

screenshot_20180823-102547

markormesher commented 6 years ago

Ah, okay now I see it. You can try swapping padding for margin, as that will create the space "outside" the layout bounds instead of inside them, but I'm not 100% sure whether that would work. If it doesn't, I can probably implement a fix over the weekend.

Yakow13 commented 6 years ago

Unfortunately, usage of margin instead of padding, doesn't make any different.

Thanks for your time :)

markormesher commented 6 years ago

What we need here is to have the FAB container still take up the full width/height of the layout (to allow the content cover to use the whole screen) and specify an internal offset to push the FAB, speed-dial and content-cover around within the bounds of the container.

If it's urgent you could do this yourself by accessing the individual views (https://github.com/markormesher/android-fab#access-to-underlying-views) and programatically moving them, but the better option is to actually implement that internal offset in the library itself. I'll take a stab at that this weekend!

markormesher commented 6 years ago

Hey @Yakow13. This should be possible now in v2.4.1 - you can set an internal offset from any of the four edges, so in your case you'd set internalOffsetEnd to be the width of the area that isn't getting covered in the screen shots above (you can do this from code or XML). The internal offset is added to the default offset, so it will appear slightly inset into the left-side area (as it does right now), rather than being right on the line between them. It's implemented this way for exactly this use case, because I think that'll be the most common usage of the feature. LMK how you get on with the update version; I'll close this for now but feel free to re-open if necessary.