Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image size too big: add position and size settings #11

Closed
jodymac opened this issue Aug 30, 2019 · 7 comments
Closed

Image size too big: add position and size settings #11

jodymac opened this issue Aug 30, 2019 · 7 comments
Labels
feature request New feature or request

Comments

@jodymac
Copy link

jodymac commented Aug 30, 2019

Thank you for making this plugin, It fills a void quite nicely! However, using the plugin, my launch image far exceeds the width (and height is huge too) of my devices. Is there a feature I missed to contain the image or pre-size the image so that it's 100% within the boundaries of the width (with some padding). Also, it would be great if we could specify image top center, or center center. For my use anyway.

@henriquearthur
Copy link
Collaborator

Currently there is no way to change the image position or size (fill, cover, contain) using the package.

There is a pull request (#8) implementing fill gravity on Android (so the image can fill 100% of the screen) merged into dev branch. I am trying to find a way to implement the same behaviour on iOS and I'll add more options like positioning the image (like top center). Once that's done it will be merged into master and a new version will be released, probably next week.

As a workaround until that happens, you can manually modify android/app/src/main/res/drawable/launch_background.xml and change android:gravity attribute on splash image bitmap to fill or clip_horizontal|clip_vertical:

<item>
    <bitmap android:gravity="fill" android:src="@drawable/splash" />
</item>

From Android docs:

  • fill: Grow the horizontal and vertical size of the object if needed so it completely fills its container.
  • clip_horizontal: Additional option that can be set to have the left and/or right edges of the child clipped to its container's bounds. The clip will be based on the horizontal gravity: a left gravity will clip the right edge, a right gravity will clip the left edge, and neither will clip both edges.
  • clip_vertical: Additional option that can be set to have the top and/or bottom edges of the child clipped to its container's bounds. The clip will be based on the vertical gravity: a top gravity will clip the bottom edge, a bottom gravity will clip the top edge, and neither will clip both edges.

On iOS, you can modify manually by using Xcode to position the image. I do not know yet how to change position by editing the code.

@henriquearthur henriquearthur added the feature request New feature or request label Aug 30, 2019
@jodymac
Copy link
Author

jodymac commented Aug 31, 2019 via email

@henriquearthur henriquearthur changed the title Image size too big Image size too big: add position and size settings Sep 1, 2019
@henriquearthur
Copy link
Collaborator

On v0.1.8+1 you can use fill property to make your image use all available width and height of the screen.

flutter_native_splash:
  fill: true

Positioning the image is not yet possible which is why I'm leaving this open, I will look into it soon.

@jodymac
Copy link
Author

jodymac commented Sep 17, 2019 via email

@erperejildo
Copy link

so instead of fill: true we could do clip_horizontal: true?

@henriquearthur
Copy link
Collaborator

so instead of fill: true we could do clip_horizontal: true?

I was thinking something like gravity: 'fill' gravity: clip_horizontal

@jonbhanson
Copy link
Owner

Commit 9a8b7ce allows the configuration of every Android gravity and iOS ContentMode option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants